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

How to make a Timer that affects all players, not just localplayer?

I've tried everything. I just can not get a timer to work without it only working for the player, and resetting every time they die. I need one for the game, because my whole game will revolve around a central round timer and when it ends. Any ideas? Here is the code that I borrowed from a youtuber, and I've tried modifying it to work for all players but it only works for a single player.

clockTimerThing = game.ReplicatedStorage:WaitForChild("ClockTimerThing")
if clockTimerThing.Value == 0 then
	repeat wait(0.1) until clockTimerThing.Value > 0	
end

 TimeInSeconds = clockTimerThing.Value
 TimeInMinutes = math.floor(TimeInSeconds/60)
 remainder = TimeInSeconds % 60
for i,v in pairs(game.Players:GetChildren()) do
 
print('1')
end
clockText = v.PlayerGui.ScreenGui.Clock


for i = 1, remainder do
	
	if TimeInMinutes > 9 then
		if remainder - i < 10 then
			clockText.Text = TimeInMinutes..":0"..remainder - i
		else
			clockText.Text = TimeInMinutes..":"..remainder - i
		end
	else
		if remainder - i < 10 then
			clockText.Text = "0"..TimeInMinutes..":0"..remainder - i
		else
			clockText.Text = "0"..TimeInMinutes..":"..remainder - i
		end
	end
end

for i = 1, TimeInMinutes do
	TimeInMinutes = TimeInMinutes - 1
	for i = 1, 60 do
		wait(1)
		if TimeInMinutes > 9 then
			if 60 - i < 10 then
				clockText.Text = TimeInMinutes..":".."0"..(60-i)
			else
				clockText.Text = TimeInMinutes..":"..(60-i)
			end
		else
			if 60 - i < 10 then
				clockText.Text = "0"..TimeInMinutes..":0"..(60-i)
			else
				clockText.Text = "0"..TimeInMinutes..":"..(60-i)
			end
		end
	end
end

2 comments

0

Could you put everything in a code block please

0

Okay I did

2 answers

use a server side script

and control it for the entire server/game

i dont even know why you would make it a script for the player

3 comments

0

I have tried using server side scripts, but I can’t access the GUI with server side scripts, I missed be a noob. If you can help out a bit more that would be great, how would I access a GUI’s properties with a server side script?

0

all active guis are stored in the player's PlayerGui, game.Players[playernamehere].PlayerGui.ScreenGui.TextLabel.Text =

You put an Value into Workspace, you make a Server script to make it a Timer. Then, from the Player, you make a LocalScript that reads the Value from the Workspace

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