The script works in Run mode but not in Play mode, no errors

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? A good timer

  2. What is the issue? It works in Run but not in Play

  3. What solutions have you tried so far? Trying to look for the issue but I dont see it

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local RunService = game:GetService("RunService")

local label = script.Parent

local function startTimer(timeLeft)

	RunService:BindToRenderStep("Timer", Enum.RenderPriority.Last.Value -1, function(delta)

		timeLeft -= delta

		local minutes = math.floor(timeLeft / 60)
		local seconds = math.floor(timeLeft % 60)
		local hundreths = math.floor(timeLeft % 1 * 100)

		label.Text = string.format("%02i:%02i.%02i", minutes, seconds, hundreths)
		if label.Text == "00:00.00" then
			label.Text = "00:00.00"
			workspace.B.Script.Disabled = false
			script:Destroy()
			
		end
	end)
end


startTimer(30)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

4 Likes

whats it parented too

is it in server script service or in the workspace or something

1 Like

It’s a textlabel. In workspace

2 Likes

It breaks on line 7 and beyond

2 Likes

This doesn’t answer your question but why do you set the text to 0 when the if statement checks if the text is 0?

2 Likes

When it reaches below 0, it just goes -1:59.99

2 Likes

How do I fix it? I want it to work

2 Likes

im trying to test it myself

right now it doesnt work

2 Likes

is it a server script or a client script?

runservice doesnt work for server scripts but when i put it on a local script it doesnt work when i run it

1 Like

its serverscript. maybe it doesnt work

oh

i dont think runservice works on server scripts

1 Like

how can i enable serverscripts with locals tho

1 Like

thats why im using servers, because locals can not enable servers

I used a local and now its broken , not text is changing

Since this is a server script, why not use Heartbeat instead of RenderStepped?

local RunService = game:GetService("RunService")

local label = script.Parent

local function startTimer(timeLeft)
	RunService.Heartbeat:Connect(function(delta)

		timeLeft -= delta

		local minutes = math.floor(timeLeft / 60)
		local seconds = math.floor(timeLeft % 60)
		local hundreths = math.floor(timeLeft % 1 * 100)

		label.Text = string.format("%02i:%02i.%02i", minutes, seconds, hundreths)
		if label.Text == "00:00.00" then
			label.Text = "00:00.00"
			workspace.B.Script.Disabled = false
			script:Destroy()
			
		end
	end)
end


startTimer(30)
3 Likes

did you try using < “00.00.01” and see if that makes a difference?