You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want this script to give the player new rock if the value changed
- What is the issue? Include screenshots / videos if possible!
It doesnt work at all
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried adding while task.wait() do, but when i did that, it worked, but it gave the player tons of same rocks
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
task.spawn(function() for _, player in pairs(game.Players:GetPlayers()) do local rock = player.leaderstats:WaitForChild("rock") rock.Changed:Connect(function(value) local therock = value.." rock" for _, currentrock in pairs(game.ServerStorage.rocks:GetChildren()) do if currentrock.Name == therock then local char = player.Character or player.CharacterAdded:Wait() for _, delete in pairs(char:GetChildren()) do if delete.Name ~= therock and delete:IsA("Tool") then delete:Destroy() end end for _, delete2 in pairs(player.Backpack:GetChildren()) do if delete2.Name ~= therock and delete2:IsA("Tool") then delete2:Destroy() end end for _, delete3 in pairs(player.StarterGear:GetChildren()) do if delete3.Name ~= therock and delete3:IsA("Tool") then delete3:Destroy() end end local clonedtool = currentrock:Clone() clonedtool.Parent = player.Backpack local clonedtool2 = currentrock:Clone() clonedtool2.Parent = player.StarterGear end end end) end end)