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)
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.
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?
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?
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.
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