So, to start off with..
It is in a Local Script.
I'm creating a shop script, that you can only buy items with points. When someone purchases the tool with points; everyone gets the tool?
I'm very concerned.
Here's the script:
local Part = game.Workspace.BuyPart local RS = game:GetService("ReplicatedStorage") local Sword = RS.Tools:FindFirstChild("SpeedCoil") local Players = game:GetService("Players") local Debounce = false Part.Touched:Connect(function(hit) local Player = game.Players.LocalPlayer if Player.leaderstats.Points.Value >= 500 then if not Debounce then Debounce = true Sword.Parent = Player.Backpack wait(10) Debounce = false end local GravityCoil = RS.Tools:FindFirstChild("GravityCoil") local Part1 = game.Workspace.BuyPart1 Part1.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if Player.leaderstats.Points.Value >= 7000 then if not Debounce then Debounce = true GravityCoil.Parent = Player.Backpack wait(10) Debounce = false end local Part2 = game.Workspace.BuyPart2 local Tool = RS.Tools:FindFirstChild("PointGiverTool") Part2.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if Player.leaderstats.Points.Value >= 10000 then if not Debounce then Debounce = true Tool.Parent = Player.Backpack wait(10) Debounce = false end end end end) end end end) end end)
--[[ I optimized your script because there were placements that shouldn't have been made. Such as 3 other Touched events in a touch event. ]] local Part = game.Workspace.BuyPart local RS = game:GetService("ReplicatedStorage") local Sword = RS.Tools:FindFirstChild("SpeedCoil") local Players = game:GetService("Players") local Debounce = false local Player = game.Players.LocalPlayer Part.Touched:connect(function(hit) -- I close each event after its done its job if Player.leaderstats.Points.Value >= 500 and not Debounce then -- Can have multiple conditional statements in one line using 'and' Debounce = true Sword:Clone().Parent = Player.Backpack -- Clone the part to avoid repetition wait(10) Debounce = false end end) local GravityCoil = RS.Tools:FindFirstChild("GravityCoil") local Part1 = game.Workspace.BuyPart1 Part1.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") and Player.leaderstats.Points.Value >= 7000 and not Debounce then Debounce = true GravityCoil:Clone().Parent = Player.Backpack wait(10) Debounce = false end end) local Part2 = game.Workspace.BuyPart2 local Tool = RS.Tools:FindFirstChild("PointGiverTool") Part2.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") and Player.leaderstats.Points.Value >= 10000 and not Debounce then Debounce = true Tool:Clone().Parent = Player.Backpack wait(10) Debounce = false end end)
That's because you didn't clone it to the backpack. If player has more points then you have to clone it to the backpack otherwise it wont work and will give the tools to everyone and.
Note: If you don't put clone this will just make the thing of the parent which you told the script plus if you want to make a bought script all you have to do is say
coins = 10 -- you can name it to anything you want coins.Value = coins.Value - Points.Value
Please upvote me if I am correct.