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

Only the server can see the timer,the player can't.Can somebody tell me what's wrong?

Asked by 5 years ago

Basically,this is my script

while wait() do
    if Players.Value >= 2 then

        StatusBar.Text = "Waiting for round start"
        for i = 10, 1, -1 do
            Timer.Text = "Time:"..i
            wait(1) 
        end



    elseif  Players.Value < 2 then
        StatusBar.Text = "There needs to be more than 1 player to begin the round."

    end
end

Only the server can see the timer. Players.Value checks how many players there are. The timer and the status bar are textlabels. My script is in ServerScriptStorage

0
Where do you see Players cant see the timer? I dont really see any connection between Server and Client. DogeIXX 172 — 5y
0
The timer just stops at like 9 seconds,that's the problem Resetname2343 -5 — 5y
0
my suggestion would be to change values in replicated storage then manually update them in the gui EmbeddedHorror 299 — 5y

1 answer

Log in to vote
0
Answered by
poke7667 142
5 years ago
Edited 5 years ago

You cannot have any scripts that modify GUIs on the server. They will work in studio because studio’s server and client are connected. However, it will error you had you tested it on an actual Roblox server. Assuming Players.Value = #Plrs:GetPlayers() then put that whole thing in a localscript and your issue with it stuck being at 9 is because you are consistently looping that for loop over and over since you have it in a continuous (while) loop. To fix that, you must use a debounce. A debounce is a variable that tells a script a chunk of code has already ran once and that you don’t want it to run again. An example is:

local debounce = false 
while wait() do
 if not debounce then -- checks if it already ran once
  debounce = true -- tells that you already ran this once
  print(“hi”)
 end
 print(“no”)
end
0
I don't get how to place the debounce in my code though Resetname2343 -5 — 5y
Ad

Answer this question