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

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

Asked by 6 years ago
Edited 6 years ago

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
0
Could you put everything in a code block please gmatchOnRoblox 103 — 6y
0
Okay I did athletics101 0 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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

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? athletics101 0 — 6y
0
all active guis are stored in the player's PlayerGui, game.Players[playernamehere].PlayerGui.ScreenGui.TextLabel.Text = fanofpixels 718 — 6y
Ad
Log in to vote
0
Answered by
Bertox 159
6 years ago
Edited 6 years ago

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

Answer this question