I have a jump over the wall game and when you jump over the wall thers a button you can stand on to make the wall highger, as the wall gets higher you have to try jump on other players to get over. Anyway everything working perfectly except one part in the code . when someone steps on the button i want it to give everyone in the server 5 Cash (currency im using). I can only get it working for one player which is the parent of the hit on the button. How can i reference all players? Here is the snippet of code i have right now local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 5
If you don't understand "for i = 1, blah blah blah" loops, go to my question about it.
You can use the ":GetChildren()" function for this.
Code:
if hit.Parent:FindFirstChild("Humanoid") then local Players = game.Players:GetChildren() for i = 1, #Players do local Player = Players[i] Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 5 end end
Hope this helped!