Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i reference all players?

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

4 comments

0

you can probably use region3 to find all players in that area but im not good with region3

0

no i just want it to give cash to all players not just in a region

0

This is a request

0

thx 4 accepting my answer! :)

1 answer

✓ Accepted answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.