Need help for a local-side timer script

So, as the title says, i am trying to make a script that would change a textvalue (for ex. There is a SurfaceGui on a brick, and a label, i want to make the label be the actual timer.
I know this can be done with:

while wait(1) do
	script.Parent.Part.SurfaceGui.TextLabel.Text = vtime
	vtime = vtime - 1
end

But that’s only server-side, is there some way to make a timer that is Client-side that affects a textlabel that is not in StarterGui, i have already tried this:

local t = workspace.Part.SurfaceGui.TextLabel
local te = 60

game.ReplicatedFirst.RemoteEvent.OnClientEvent:Connect(function()
	print("catch")
	while wait(0.1) do
		te = te - 0.1
		t.Text = tostring(te)
	end
end)

That did not work.

If anyone has a solution, please let me know!

1 Like

I suggest to make it just a little smaller using:

vtime -= 1

if that doesn’t work use instead:

vtime += -1

I suggest adding to the while wait the following as well:

  1. A print which prints the time just to check if it works
  2. checking if te is not lower or equal to 0;
while wait(0.1) and te <= 0 do

Tho I am not sure what kind of issue you’re facing here to be really honest, as this should work just fine.

Well the actual problem is, it’s in a localscript, yes. But then, it does not modify the actual textlabel, not on the client or the actual server itself.
This is how i have set it up.

try placing the localscript in starter gui and instead of using “while wait do” try using
“Repeat wait() Until te == 0” this is a better way of making a loop that has an ending to it.

Ah yes,
Instead of the while loop you could use:

repeat 
	te += -.1
until te <= 0

UPDATE: I have now ran into a problem, the event does not seem to register itself being fired, even after using the developer console, it does not output the command i gave it, is this a bug?

then check the source that fired the event if it’s firing it properly or is there an error in the output

Problem.

Don’t mind the 1 errors in console, i know how to fix it, it is not related to that.

How are you firing the event: by touch?, mouse clicking?

Like shown on the video, fired from server:
game.ReplicatedFirst.RemoteEvent:FireAllClients()

i recommend opening the output source and checking the error from there

None. I know what that error is, i can fix it. It’s just confusing, shouldnt it output “game.ReplicatedFirst.RemoteEvent:FireAllClients()” in the console as i executed it?image

click the cleint button to check if the event was fired to there because you said you fired it from the serverside to the cleintside so click the cleint button and check.

did you fix it or found a solution?

No, nothing is being outputted.

did you include a print() in the localscript to know when it’s fired?

Place this in a local script inside of your text label

local function toMS(s)
	return ("%02i:%02i"):format(s/60%60, s%60)
end

for i = 600, 1, -1 do
	wait(1)
	script.Parent.Text = toMS(i)
	if script.Parent.Text == ("00:00") then

	end
end

hope it works!

[EDIT] change the 600 in for i = 600, 1, -1 do for your minutes in seconds e.g. 300 seconds = 5 minutes

he is trying to know when an event is fired not to make a complex timer

To the 1st one: I did, it did not work, keep in mind this is a surfacegui textlabel, not GUI textlabel.

To the 2nd one: Yes, i did, it does not work!

UPDATE: I think something is wrong with my studion installation.

no i don’t think so, ok let me make it in studio and comeback