Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do i reference all players?

Asked by 3 years ago

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

0
you can probably use region3 to find all players in that area but im not good with region3 Omzure 94 — 3y
0
no i just want it to give cash to all players not just in a region true_200ping 2 — 3y
0
This is a request JailBreaker_13 350 — 3y
0
thx 4 accepting my answer! :) Zeuxulaz 148 — 3y

1 answer

Log in to vote
1
Answered by
Zeuxulaz 148
3 years ago

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!

Ad

Answer this question