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

I need help with a code to get all players in server this amount of cash? {CODE DOWN BELOW]

Asked by 5 years ago

game.Players.(Playername).leaderstats.Cash.Value = number

So the code below is a test for my game. However, I don't want it to be a particular player, I want it to include all players in the server. For example I don't want it to be one player like this: game.Players.Playername

Instead I want it to be all players.

Can you help me find a code that does the exact same function but with all players included in the server?

Thanks.

1 answer

Log in to vote
0
Answered by 5 years ago

Use a for loop, to iterate through the players. v will be the player being iterated through. So you can use v.leaderstats, v.Character, etc.

for _, v in pairs(game:GetService("Players"):GetPlayers()) do
    -- Code
end
1
I'm so sorry I'm a complete beginner, I did not understand any of that can you just give me the full code? Please. ProductiveInc 10 — 5y
0
In line 2, just put v.leaderstats.Cash.Value = NUMBER HERE User#19524 175 — 5y
0
Thank you so much man! ProductiveInc 10 — 5y
Ad

Answer this question