Stopwatch time not being put into StringValue

I’ve tried IntValue and NumberValue but the stopwatch system has unsupported characters that prevent it.
This is the part of the script that i’ve been looking at. (I remember following a tutorial for this because i was struggling)

    if hit.Parent.Name == game.Players.LocalPlayer.Name then
        Running = false
        Run = false
        if (Minutes*59.999 + Time) < BestTime and (Minutes*59.999 + Time) > 0.001 then
            BestTime = Minutes*59.999 + Time
            BestTimeText.Text = "Best Time: "..ActualTimeText.Text
			BestTimeEvent:FireServer(ActualTimeText.Text, game.Players.LocalPlayer)
			print(ActualTimeText.Text)
			script.Parent.Time.Value = ActualTimeText.Text
		end
        wait(3)
        Stopwatch.Enabled = false
        Time = 0
		Minutes = 0
    end
end)

This part is what i’ve added recently

print(ActualTimeText.Text)
script.Parent.Time.Value = ActualTimeText.Text

The print works, but the 2nd line doesn’t seem to add the value.

This is the explorer window for the objects
image

Any help is really appreciated!

1 Like

Have you tried tostring()? It converts everything the brackets to a string (if it supported character like A number) I don’t see it at all in the script.

1 Like

I have not, how would I do that?

1 Like

Tostring() is a roblox built-in function that inside the brackets will convert to a string pretty simple so in your script it would look like

if hit.Parent.Name == game.Players.LocalPlayer.Name then
        Running = false
        Run = false
        if (Minutes*59.999 + Time) < BestTime and (Minutes*59.999 + Time) > 0.001 then
            BestTime = tostring((Minutes*59.999 + Time))
            BestTimeText.Text = "Best Time: "..ActualTimeText.Text
			BestTimeEvent:FireServer(ActualTimeText.Text, game.Players.LocalPlayer)
			print(ActualTimeText.Text)
			script.Parent.Time.Value = ActualTimeText.Text
		end
        wait(3)
        Stopwatch.Enabled = false
        Time = 0
		Minutes = 0
    end
end)

That should be it if theres any spelling mistakes that on me bc im typing on mobile.

Also another thing when firing a remoteevent to the sever the first argument is the player who sent it (in the sever script). So there is no need on line 7 to be sending the local player over. Thats just wasting resources. Thank you for reading.

I completely forgot to mention which variable I wanted, apologies.
I’m trying to add the ActualTimeText variable

Im confused, if your trying to turn the text into a string it should already be a string. Are you trying to set the stringvalue on the client on while checking on the sever? Because when you set something in a local script THE ONLY person who can see it is your character/player so set the varible on the server if your trying to access it on the sever

Also what is the actualtimetext variable set to?

image

This already looks convoluted. It’s possible to record time in milliseconds and simply use math or DateTime to format the milliseconds to hours, minutes, seconds, and such. This is generally what professional projects do

Pretty sure most of it is done on the client.
I have an endpoint and when touched it stops the timer and shows a level completed GUI.
The level completed GUI has text that shows the time taken but the script that edits the text for the gui is in a different script to the stopwatch GUI

If time is not actively shown, then there is no need to record anything but a beginning timestamp. Once again, math can be used to determine the elapsed milliseconds

Time is constantly shown at the bottom of the screen

No issue, you just can’t use timestamps

How would I do the math for the time?
I feel like that could work, but i’m looking for the format of “00:00.000”

local milliseconds = Milliseconds.Value

stopwatch.Text = string.format("%02d:%.2f", milliseconds // 60, milliseconds % 60)

Where Milliseconds is a NumberValue that accumulates the delta-times of RunService.PostSimulation