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

A better way of tracking round time?

Currently, I'm making use of a time attribute in the workspace; to which a UI listens for changes to and updates itself accordingly. Like so:

workspace:GetAttributeChangedSignal("Time"):Connect(function()
	label.Text = workspace:GetAttribute("Time")
end)

Although it works perfectly fine, it seems a little inelegant to me. Is there another/better way of tracking time, which does not involve IntValues or attributes?

Is it better if I use a remote event instead? For example:

-- server script
local timer = 15
while timer > 0 do
	remote:FireAllClients(timer)
	wait(1)
	timer -= 1
end

-- local script
remote.OnClientEvent:Connect(function(timer)
	label.Text = timer
end)

1 answer

✓ Accepted answer
  1. You don't have to use a remote event.
  2. It's completely fine how you do it.

I usually do this this way just 2 lines of plain code. Wrap it in a spawn() or Coroutine in case it interrupts other parts of scripts.

local timer = 15
repeat wait(1) timer -= 1 until timer <= 0 
-- hit 0 then run other functions

You can also send the info via Remoteevent if you like to:

local timer = 15
repeat wait(1) timer -= 1 remote:FireAllClients(timer) until timer <= 0 
-- hit 0 then run other functions

Or change an IntValue or SetAttribute to it.

2 comments

0

To give the client the current value of the timer make an Attribute or Intvalue displaying it and get changed signal.

1

I take it that there's no better way. Since you're the only answer I'll accept it.

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