You'll have to learn how to use for loops to achieve what you want. for loops can either be generic or numeric, and in your case we'll use a generic one.
Here's a small example of a generic for loop:
local Players = game:GetService("Players")
for index, value in pairs(Players:GetPlayers()) do
print(index, value)
end
You'll notice it prints something like
1 WaterIsIceSoup
and that's cool and all. What this is doing is going through the table of :GetPlayers(), which looks like this if I'm alone in a server:
{game.Players.WaterIsIceSoup} - note that it is a direct reference to my Player object.
Using our newfound knowledge, we can create a script to affect all Players ingame.
local Players = game:GetService("Players")
for index, player in pairs(Players:GetPlayers()) do
player:LoadCharacter()
end
This script respawns everyone in the game. n i f t y.
If you wanted to change a value in every player, that'd look something like this:
local Players = game:GetService("Players")
for index, player in pairs(Players:GetPlayers()) do
player.Wins.Value = 9999
end
The problem is that your value is inside the TextLabel. Server scripts by default cannot see any GUI in a PlayerGui, and should not attempt to handle them.
What I suggest is putting the IntValue inside the Player itself when they join, then use the above example to modify every player's stats. You'll need to use PlayerAdded to put the IntValue in Players when they join.
Wiki articles on PlayerAdded.
https://developer.roblox.com/en-us/api-reference/event/Players/PlayerAdded
Hopefully this sets you on the right track.
1 comment
I tried the for loop but totally forgot the :GetPlayers() function, thanks so much!