I have recently been making a game where I need a certain value to increase by another value, however, the script doesn´t work and I can´t figure out why. The output keeps telling me that leaderstats isn´t a valid child of player.
script.Parent.Touched:Connect(function(player)
player:WaitForChild("leaderstats").Money.Value = player:WaitForChild("leaderstats").Money.Value + player:WaitForChild("leaderstats").Trash.Value
player:WaitForChild("leaderstats").Trash.Value = 0
end)

6 comments
https://scriptinghelpers.org/questions/72930/solved-leaderstats-isnt-a-valid-member-of-player
But I am doing it in a server script.
And it all works except from this part.
Posting the output as intact as possible would be of much help.
22:17:11.961 - Infinite yield possible on 'Workspace.Baseplate:WaitForChild("leaderstats")' 22:17:11.963 - Stack Begin 22:17:11.964 - Script 'Workspace.DumpingPart.Script', Line 2 22:17:11.965 - Stack End
Well that would explain it, hold on.