Here is the code:
local valueRequired = 100 game.Players.PlayerAdded:Connect(function(plr) local stat = plr:WaitForChild("leaderstats"):WaitForChild("Cash") stat.Changed:Connect(function(val) if val >= 100 then local tool = game.ServerStorage["SapphireCane"]:Clone() tool.Parent = plr.Backpack plr.CharacterAdded:Connect(function() local tool = game.ServerStorage["SapphireCane"]:Clone() tool.Parent = plr:WaitForChild("Backpack") end) end end) end)
How would I stop making this happen so I do not get a bunch of the tool? For I get one tool every time my money changes, and I only want it to happen once.
local valueRequired = 100 game.Players.PlayerAdded:Connect(function(plr) local stat = plr:WaitForChild("leaderstats"):WaitForChild("Cash") local hasGotten = false stat.Changed:Connect(function(val) if val >= 100 and hasGotten == false then hasGotten = true local tool = game.ServerStorage["SapphireCane"]:Clone() tool.Parent = plr.Backpack plr.CharacterAdded:Connect(function() local tool = game.ServerStorage["SapphireCane"]:Clone() tool.Parent = plr:WaitForChild("Backpack") end) end end) end)