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.
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
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)
--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”