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

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

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

3 comments

0

Where do you see Players cant see the timer? I dont really see any connection between Server and Client.

0

The timer just stops at like 9 seconds,that's the problem

0

my suggestion would be to change values in replicated storage then manually update them in the gui

1 answer

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

1 comment

0

I don't get how to place the debounce in my code though

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