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

How do I make this script work for every1 at the same time?

Asked by 6 years ago
Edited 6 years ago

so this script is a countdown gui. i forgot how to make it so it works for everyone at the same time. for instance, if someone joins and it begins counting down from 45, when the next person joins it should not start at 45 again, it should be whatever number the first person who joined is.

while true do local time = 45 for i = 1, 45 do wait(1) time = time - 1 script.Parent.Text = tostring(time) end script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 100 end

0
It messed up the code ugh. that should be 9 lines not 3 lol. yodaxvader 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You could do this server-side with a server (regular) script. Then when the countdown ends, you can use a for loop to get every player and put their health to 100.

The loop would be something like this :

for i,plr in pairs(game.Players:GetPlayers()) do
plr.Character.Humanoid.Health = 100
end

Typed this on mobile so sorry if it looks weird. :P

Ad

Answer this question