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

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

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

✓ Accepted answer

###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

3 comments

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.

0

In line 2, just put v.leaderstats.Cash.Value = NUMBER HERE

0

Thank you so much man!

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