Advertisement
qsenko1

ShopStands Prototype

Feb 18th, 2022
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.02 KB | None | 0 0
  1. -- Server Script
  2. local ProximityPromptService = game:GetService("ProximityPromptService")
  3. local Stands = game.Workspace.ShopStands
  4. local ShopEvent = game.ReplicatedStorage.ShopEvent
  5. local ProximityPromptUpdater = game.ReplicatedStorage.ProximityPromptUpdater
  6. local debounce = true
  7.  
  8. game.Players.PlayerAdded:Connect(function(Player)
  9.     local PlayerStandCheck = Instance.new("BoolValue")
  10.     PlayerStandCheck.Parent = Player
  11.     PlayerStandCheck.Value = false
  12.     PlayerStandCheck.Name = "PlayerStandCheck"
  13.     for i,stands in pairs(Stands:GetDescendants()) do
  14.         if stands:IsA("Model") and stands.Name == "ShopStand" then
  15.             stands:FindFirstChild("PricePart").Attachment.ProximityPrompt.Triggered:Connect(function(Player)
  16.                 if stands:FindFirstChild("Owned").Value == false and stands:FindFirstChild("PlayerName").Value == "" and Player:FindFirstChild("PlayerStandCheck").Value ~= true then -- and debounce
  17.                     --  print(Player)
  18.                     --debounce = false
  19.                     Player:FindFirstChild("PlayerStandCheck").Value = true
  20.                     stands:FindFirstChild("Owned").Value = true
  21.                     stands:FindFirstChild("PlayerName").Value = Player.Name
  22.                     stands:FindFirstChild("DescriptionPart").SurfaceGui.PlayerName.Text = Player.Name  .. "'s stand"
  23.                     stands:FindFirstChild("DescriptionPart").SurfaceGui.PriceRaised.Text = Player.leaderstats.Raised.Value .. " raised"
  24.                     stands:FindFirstChild("DescriptionPart").SurfaceGui.PriceRaised.Visible = true 
  25.                 --  stands.PricePart.SurfaceGui.Enabled = true -- player ownes clothes
  26.                     local Song = "Level Up"
  27.                     ShopEvent:FireClient(Player,Song)
  28.                     ProximityPromptUpdater:FireAllClients(Player)
  29.                     print("1")
  30.                 --return
  31.                 elseif stands:FindFirstChild("Owned").Value == true and stands:FindFirstChild("PlayerName").Value == Player.Name then
  32.                 --  stands.TextPart.SurfaceGui.TextLabel.Text = "StartTextEdit"
  33.                 --  debounce = false
  34.                     print("Its Your Stand")
  35.                     local Song = "Open Shop"
  36.                     ShopEvent:FireClient(Player,Song)
  37.                     print("2")
  38.                 elseif stands:FindFirstChild("Owned").Value == false and stands:FindFirstChild("PlayerName").Value == "" then
  39.                 --  debounce = false
  40.                     local Song = "No"
  41.                     ShopEvent:FireClient(Player,Song)
  42.                     print("you already have a stand")
  43.                     print("3")
  44.                 end
  45.             --  debounce = true
  46.             end)
  47.         end
  48.     end
  49.     Player.CharacterAdded:Connect(function(Character)
  50.         task.wait(.5)
  51.         print("ProximityPromptUpdater fired")
  52.         ProximityPromptUpdater:FireAllClients(Player)
  53.     end)
  54. end)
  55.  
  56. game.Players.PlayerRemoving:Connect(function(Player)
  57.     for i,stands in pairs(Stands:GetDescendants()) do
  58.         if stands:IsA("Model") and stands.Name == "ShopStand" then
  59.             if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
  60.                 stands.TextPart.SurfaceGui:FindFirstChild("TextLabel").Text = "Your Text Here"
  61.                 stands.DescriptionPart.SurfaceGui:FindFirstChild("PlayerName").Text = "unclaimed"
  62.                 stands.DescriptionPart.SurfaceGui:FindFirstChild("PriceRaised").Visible = false
  63.                 stands:FindFirstChild("PricePart").Attachment.ProximityPrompt.Enabled = true
  64.                 stands:FindFirstChild("Owned").Value = false
  65.                 stands:FindFirstChild("PlayerName").Value = ""
  66.                 ProximityPromptUpdater:FireAllClients(Player)
  67.                 print("Someone Left")
  68.             end
  69.         end
  70.     end
  71. end)
  72.  
  73. -- Update The Text thats Applied
  74. ShopEvent.OnServerEvent:Connect(function(Player,DescriptionBoardText)
  75.     --print(DescriptionBoardText)
  76.     for i,stands in pairs(Stands:GetDescendants()) do
  77.         if stands:IsA("Model") and stands.Name == "ShopStand" then
  78.             if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
  79.                 stands.TextPart.SurfaceGui:FindFirstChild("TextLabel").Text = DescriptionBoardText
  80.             end
  81.         end
  82.     end
  83. end)
  84. -- Local Script
  85. local TweenService = game:GetService("TweenService")
  86. local ProximityPromptService = game:GetService("ProximityPromptService")
  87. local ReplicateStorage = game:GetService("ReplicatedStorage")
  88. local ShopEvent = ReplicateStorage:WaitForChild("ShopEvent")
  89. local ProximityPromptUpdater = ReplicateStorage:WaitForChild("ProximityPromptUpdater")
  90. local Player = game.Players.LocalPlayer
  91. local Stands = game.Workspace.ShopStands
  92. local Camera = workspace.CurrentCamera
  93. Player.CharacterAdded:Wait()
  94. local RefreshButton = Player.PlayerGui:WaitForChild("EditTextGui").Frame.RefreshButton
  95. local CancelButton = Player.PlayerGui:WaitForChild("EditTextGui").Frame.CancelButton
  96. local ApplyButton = Player.PlayerGui:WaitForChild("EditTextGui").Frame.ApplyButton
  97. local TextBox = Player.PlayerGui:WaitForChild("EditTextGui").Frame.TextBox
  98. local DescriptionText = Player.PlayerGui:WaitForChild("DescriptionGui").Frame.TextLabel
  99. local debounce = true
  100.  
  101. local function ShopOpen()
  102.     local Blur = Instance.new("BlurEffect")
  103.     Blur.Parent = game.Lighting
  104.     Blur.Size = 10
  105.     Player.PlayerGui:WaitForChild("EditTextGui").Enabled = true
  106.     local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
  107.     local object = Camera
  108.     local object2 = Player.PlayerGui:WaitForChild("EditTextGui").Frame
  109.     local goal = {FieldOfView = 60}
  110.     local goal2 = {Position = UDim2.new(0.3, 0, 0.25, 0)}
  111.     local tween = TweenService:Create(object, tweenInfo, goal)
  112.     local tween2 = TweenService:Create(object2, tweenInfo, goal2)
  113.     tween:Play()
  114.     tween2:Play()
  115.     --task.wait(2) -- Not sure if should keep the wait
  116.     --Camera.FieldOfView = 70
  117.     --Blur:Destroy()
  118. end
  119.  
  120. local function Blink()
  121.     local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
  122.     local object = DescriptionText
  123.     local goal = {TextTransparency = 1,Position = UDim2.new(0.349, 0, 0.603, 0)}
  124.     local tween = TweenService:Create(object, tweenInfo, goal)
  125.     tween:Play()
  126. end
  127.  
  128. local function ShopClaim()
  129.     local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
  130.     local object = DescriptionText
  131.     local object2 = Camera
  132.     local goal = {TextTransparency = 1,Position = UDim2.new(0.349, 0, 0.74, 0)}
  133.     local goal2 = {FieldOfView = 70}
  134.     local tween = TweenService:Create(object, tweenInfo, goal)
  135.     local tween2 = TweenService:Create(object2, tweenInfo, goal2)
  136.     tween:Play()
  137.     tween2:Play()
  138. end
  139.  
  140. ApplyButton.MouseButton1Up:Connect(function()
  141.     for i,stands in pairs(Stands:GetDescendants()) do
  142.         if stands:IsA("Model") and stands.Name == "ShopStand" then
  143.             if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
  144.                 stands.TextPart.SurfaceGui.TextLabel.Text = TextBox.Text
  145.                 local DescriptionBoardText = TextBox.Text
  146.                 ShopEvent:FireServer(DescriptionBoardText)
  147.                 Player.PlayerGui:WaitForChild("EditTextGui").Enabled = false
  148.                 local Blur = game.Lighting:FindFirstChild("Blur"):Destroy()
  149.                 local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
  150.                 local object = Camera
  151.                 local object2 = Player.PlayerGui:WaitForChild("DescriptionGui").Frame.TextLabel
  152.                 local goal = {FieldOfView = 70}
  153.                 local goal2 = {TextTransparency = 1,Position = UDim2.new(0.349, 0, 0.603, 0)}
  154.                 Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  155.                 Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextTransparency = 0   
  156.                 Player.PlayerGui.DescriptionGui.Frame.TextLabel.Visible = true
  157.                 Player.PlayerGui.DescriptionGui.Frame.TextLabel.Text = "applied!"
  158.                 Player.PlayerGui.LocalSounds:FindFirstChild("Level Up Sound Effect"):Play()
  159.                 local tween = TweenService:Create(object, tweenInfo, goal)
  160.                 local tween2 = TweenService:Create(object2, tweenInfo, goal2)
  161.                 for i,stands in pairs(Stands:GetDescendants()) do
  162.                     if stands:IsA("Model") and stands.Name == "ShopStand" then
  163.                         if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
  164.                             stands.PricePart.Attachment:FindFirstChild("ProximityPrompt").Enabled = true
  165.                             tween:Play()
  166.                             tween2:Play()
  167.                             task.wait(.4)
  168.                             object2.Position = UDim2.new(0.349, 0,0.74, 0)
  169.                             --Player.PlayerGui.DescriptionGui.Frame.TextLabel.Visible = false
  170.                         end
  171.                     end
  172.                 end
  173.             end
  174.         end
  175.     end
  176. end)
  177.  
  178. RefreshButton.MouseButton1Up:Connect(function()
  179.     -- Refresh the clothes i guess and do some other stuff 
  180. end)
  181.  
  182. CancelButton.MouseButton1Up:Connect(function()
  183.     Player.PlayerGui:WaitForChild("EditTextGui").Enabled = false
  184.     local Blur = game.Lighting:FindFirstChild("Blur"):Destroy()
  185.     local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
  186.     local object = Camera
  187.     local object2 = Player.PlayerGui:WaitForChild("DescriptionGui").Frame.TextLabel
  188.     local goal = {FieldOfView = 70}
  189.     local goal2 = {TextTransparency = 1,Position = UDim2.new(0.349, 0, 0.603, 0)}
  190.     Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
  191.     Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextTransparency = 0   
  192.     Player.PlayerGui.DescriptionGui.Frame.TextLabel.Visible = true
  193.     Player.PlayerGui.DescriptionGui.Frame.TextLabel.Text = "canceled!"
  194.     Player.PlayerGui:WaitForChild("LocalSounds").CloseButton:Play()
  195.     local tween = TweenService:Create(object, tweenInfo, goal)
  196.     local tween2 = TweenService:Create(object2, tweenInfo, goal2)
  197.     for i,stands in pairs(Stands:GetDescendants()) do
  198.         if stands:IsA("Model") and stands.Name == "ShopStand" then
  199.             if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
  200.                 stands.PricePart.Attachment:FindFirstChild("ProximityPrompt").Enabled = true
  201.                 tween:Play()
  202.                 tween2:Play()
  203.                 task.wait(.4)
  204.                 object2.Position = UDim2.new(0.349, 0,0.74, 0)
  205.             end
  206.         end
  207.     end
  208. end)
  209.  
  210. ShopEvent.OnClientEvent:Connect(function(Song)
  211.     print(Song)
  212.     print("debounce is:" .. tostring(debounce))
  213.     if Song == "Level Up" and debounce then
  214.         debounce = false
  215.         Player.PlayerGui.LocalSounds:FindFirstChild("Level Up Sound Effect"):Play()
  216.         local UIStroke = Instance.new("UIStroke")
  217.         UIStroke.Thickness = 3
  218.         UIStroke.ApplyStrokeMode = "Contextual"
  219.         UIStroke.Parent = Player.PlayerGui.DescriptionGui.Frame.TextLabel
  220.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
  221.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.Text = "Claimed"
  222.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.Visible = true
  223.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextTransparency = 0
  224.         DescriptionText.Position = UDim2.new(0.349, 0,0.603, 0)
  225.         Camera.FieldOfView = 60
  226.         ShopClaim()
  227.         task.wait(.4)
  228.         UIStroke:Destroy()
  229.         print("Claiming Shop")
  230.     elseif Song == "No" and debounce then
  231.         debounce = false
  232.         Player.PlayerGui.LocalSounds:FindFirstChild("no! sound effect"):Play()
  233.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  234.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.Text = "u already have a booth!"
  235.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.Visible = true
  236.         Player.PlayerGui.DescriptionGui.Frame.TextLabel.TextTransparency = 0
  237.         -- DescriptionText.Position = UDim2.new(0.349, 0,0.603, 0)
  238.         Blink()
  239.         task.wait(.45)
  240.         DescriptionText.Position = UDim2.new(0.349, 0,0.74, 0)
  241.         print("NO")
  242.     elseif Song == "Open Shop" and debounce then
  243.         debounce = false
  244.         print("Opening Shop")
  245.         ShopOpen()
  246.     for i,stands in pairs(Stands:GetDescendants()) do
  247.             if stands:IsA("Model") and stands.Name == "ShopStand" then
  248.                 print(stands.Owned.Value == true)
  249.                 print(stands.PlayerName.Value == Player.Name)
  250.                 if stands:FindFirstChild("Owned").Value == true and stands:FindFirstChild("PlayerName").Value == Player.Name then
  251.             --      debounce = false
  252.                     stands.PricePart.Attachment:FindFirstChild("ProximityPrompt").Enabled = false
  253.                     --wait(5)
  254.                     --ShopOpen()
  255.                     print("3")
  256.                 end
  257.             end
  258.         end
  259.     end
  260.     wait(.5)
  261.   debounce = true
  262. end)
  263.  
  264. ProximityPromptUpdater.OnClientEvent:Connect(function()
  265.     for i,stands in pairs(Stands:GetDescendants()) do
  266.         if stands:IsA("Model") and stands.Name == "ShopStand" then
  267.             if stands.Owned.Value == true and stands.PlayerName.Value ~= Player.Name then
  268.                 stands.PricePart.Attachment.ProximityPrompt.Enabled = false
  269.             elseif stands.Owned.Value == false and stands.PlayerName.Value == "" then
  270.                 stands.PricePart.Attachment.ProximityPrompt.Enabled = true
  271.             end
  272.         end
  273.     end
  274. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement