I have not been able to figure out how to run a timer server side and then transfer the time to the client side so that when they die, the time keeps running and doesn’t get reset. I’ve tried remote functions and events. Any suggestions?
COMMUNITY QUESTION
How to make a timer that runs server side and affects clients?
1 answer
There's a few ways you could do this
Option 1: Have an int value the server updates to count down, which is accessible by the client so long as it's somewhere it can access like workspace.
-------------------------
Option 2: Use a remote function to return the time left when the client requests it;
Server script:
local timeLeft = 100
spawn(function()
for i = 100, 1, -1 do
wait(1)
timeLeft = i
end
end)
function GetTime()
return timeLeft
end
script.RemoteFunction.OnServerInvoke = GetTime
Local script:
while wait(1) do
print(workspace.GetTime.RemoteFunction:InvokeServer())
end
-------------------------
Option 3: Have the server send the time to all the clients every 1 second;
Server script:
local timeLeft = 100
spawn(function()
for i = 100, 1, -1 do
wait(1)
timeLeft = i
script.RemoteEvent:FireAllClients(timeLeft)
end
end)
Local script:
workspace.GetTime.RemoteEvent.OnClientEvent:Connect(function(timeLeft)
print(timeLeft)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
have you really tried