How do you make a GUI for the whole server?

Hello, I was coding a Timer GUI and I noticed it was local not on the server, I wanted to know how to make It on the server I asked some people on discord servers but nothing. SO I came to ask you guys because you guys are a BIG BRAIN COMMUNITY so If you know how to make a GUI on the server side please tell me. Thank you for reading.

Sincerely, DevBattery

CODE:


local length = 30

local Active = true

local Outcomes = { "Obby1", "Obby2", "Obby3"}

ClickButton.ClickDetector.MouseClick:Connect(function(player)
	local GUI = player:FindFirstChild("PlayerGui")
	local Timer = GUI:FindFirstChild("Timer")
	--if on
	if Active == true then
		print("Button on")
		local Obby = game:GetService("ServerStorage")[Outcomes[math.random(1, #Outcomes)]]:Clone()
		Obby.Parent = workspace
		Active = false
		--timer
		repeat  
			wait(1)
			Timer.TextLabel.Text = length 
			
			length = length - 1
			
			until length == 0
          

		Active = true
		Obby:Destroy()
	end

--If button is off
	if Active == false then
		print("Button off")
    end
end)  



![image|337x500](upload://3lCnkMEcP6U6yG1J47A7HwnQEgu.png) 


Note: The timer and button works

You should use RemoteEvents and fire all the countdown code on the client. This will happen to everyone. GUIS are on the client so you can’t edit it on server.

Edit: Also please format your code with ``` please.

2 Likes

Hey, you are going in the right direction! Using the starter GUI will give all the players that join a copy of what’s put in there. Make sure you put all the assets that you would be needing in the GUI. Then, if you want to update certain parts of the GUI, use a Remote event to do so. Use them to communicate from the server and the client.

Edit: For goodness sake, use block codes when you paste stuff here :joy:

2 Likes

What type of remote event would I have to use?

in round based games they’re mostly putting an intvalue inside replicatedstorage and doing this in textlabel (i believe)

script.Parent.Text = game.ReplicatedStorage.Timer.Value

and that’s what i do for my round systems and if you change this value with a server script every player will have same changes.

1 Like

Ok so I did what you said and it didn’t work thanks for trying but I think your on to something.

sure thing i only have a main script here it is (in sss as a normal script)


local length = game.ReplicatedStorage.length.Value

local Active = true

local Outcomes = { "Obby1", "Obby2", "Obby3"}



ClickButton.ClickDetector.MouseClick:Connect(function(player)
	local GUI = player:FindFirstChild("PlayerGui")
	local Timer = GUI:FindFirstChild("Timer")
	--if on
	if Active == true then
		print("Button on")
		local Obby = game:GetService("ServerStorage")[Outcomes[math.random(1, #Outcomes)]]:Clone()
		Obby.Parent = workspace
		Active = false
		
		
-------------timer--------------------------------------------------------------------------------
		
		
		repeat  
			wait(1)
			Timer.TextLabel.Text = length 
			
			length = length - 1
			
			until length == 0
		length = 30
		Timer.TextLabel.Text = "Game ended"
		wait(1)
		Timer.TextLabel.Text = ""
		Active = true
		Obby:Destroy()
	
	
	end

--If button is off
	if Active == false then
		print("Button off")
    end
end)    

Heres an image that may help

\

ok so I’ll put some part of my scripts here:

--This is the local script inside Textlabel

local timer = game.ReplicatedStorage.Timer

script.Parent.Text = timer.Value

timer.Changed:Connect(function()
   script.Parent.Text = timer.Value
end)
--This is the regular script inside ServerScriptService

local timer = game.ReplicatedStorage.Timer

local lengthTime = 30

while true do
   timer.Value = lengthTime

   repeat

      timer.Value -= 1
      wait(1)

   until timer.Value <= 0
end

maybe try these? but if you’re going to test this make sure your intvalue inside replicatedstorage is named “Timer”

2 Likes

It worked thanks :slight_smile: ill be sure to learn from this!

Edit: Theres a problem the timer keeps looping over and over even when the timer hits 0

When I remove the while loop the timer doesnt display

do you get any errors in the script?

nope no errors in the code everything is fine.

maybe add wait(1) above repeat loop?

nope did not work i dont think its that

when i use repeat until it doesnt even display the timer

try using for loop then?

for i = lengthTime, 0, -1 do
   timer.Value = i
   wait(1)
end

if you are doing in a normal script then this and shouldn’t happen