Hi,
I made a timer script and it’s my first time using coroutine so I just want to know if I can improve or correct something
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunTimer = ReplicatedStorage:WaitForChild("RunTimer")
local GamePart = ReplicatedStorage:WaitForChild("GamePart")
local Timer = ReplicatedStorage:WaitForChild("Timer")
local runTimer = coroutine.create(function(seconds)
local timerStopTime = time() + seconds
while task.wait() do
local timeNow = time()
if timeNow < timerStopTime then
Timer.Value = timerStopTime - timeNow
else
if Timer.StartNextGamePartAtZero.Value then
GamePart.Value += 1
end
local seconds = coroutine.yield()
timerStopTime = time() + seconds
end
end
end)
RunTimer.Event:Connect(function(seconds)
coroutine.resume(runTimer, seconds)
end)
GamePart.Value = 1
edit: it works if someone ask