How to change the value to what is in the TextLabel?

Hello everyone, I’m making a speedrun system for my game and I want to make the value change depending on the end time in the TextLabel. I don’t know why, but the timer stops but the value does not change at all. I will be very grateful for your help. Here’s the script:

local TimerGo = game.ReplicatedStorage:WaitForChild("TimerGo")
local TimerStop = game.ReplicatedStorage:WaitForChild("TimerStop")

TimerGo.OnServerEvent:Connect(function(player)
	
	player:WaitForChild("PlayerGui"):WaitForChild("SpeedRunTimeGui"):WaitForChild("SpeedRunTimerGui"):WaitForChild("Timer").Enabled = true
	
end)

TimerStop.OnServerEvent:Connect(function(player)
		
	player:WaitForChild("PlayerGui"):WaitForChild("SpeedRunTimeGui"):WaitForChild("SpeedRunTimerGui"):WaitForChild("Timer").Enabled = false
	
	player:WaitForChild("StatsFolder"):WaitForChild("SpeedRunTime").Value = player:WaitForChild("PlayerGui"):WaitForChild("SpeedRunTimeGui"):WaitForChild("SpeedRunTimerGui").Text
	
end)

2 Likes

If you mean the second to last line then you would have to change it to:

player:WaitForChild("StatsFolder"):WaitForChild("SpeedRunTime").Value = tonumber(player:WaitForChild("PlayerGui"):WaitForChild("SpeedRunTimeGui"):WaitForChild("SpeedRunTimerGui").Text)

Because you can’t set a number value to a string value and you would have to do add the tonumber() and put the rest of the code in the line which is this part:

player:WaitForChild("PlayerGui"):WaitForChild("SpeedRunTimeGui"):WaitForChild("SpeedRunTimerGui").Text)

inside the parantheses.

I hope this somewhat explains this. I learned this when in a quick sort algorithm I made where I was trying to get the number in a text box and change a certain value based off of it.

1 Like

I’ll try it now and let you know the result

Doesn’t work, the value is still zero

Desktop Screenshot 2023.10.31 - 21.08.30.37

If anything, this is what my timer looks like

Okay, can you print the line using this to check if the value returns nil or something

print(tonumber(player:WaitForChild("PlayerGui"):WaitForChild("SpeedRunTimeGui"):WaitForChild("SpeedRunTimerGui").Text))

I checked and it said “nil” in the output.

okay, can I see your explorer of the speed run timers text thing? I have had this issue where it does nil before.

Sorry for the stupid question, but what is this like?

If you are talking about the explorer than it looks like this:
Explorer Icons have bad readability - Studio Features - Developer Forum |  Roblox

Can you use something to screenshot the path it takes down to the text under your speedrun timer?


How did I understand this?

Okay, one more thing you can add to your script is printing the textlabels text. Can you try this and see what the output says?

prints nil on output, Is this how it should be?

If your simply just using

print(player:WaitForChild("PlayerGui"):WaitForChild("SpeedRunTimeGui"):WaitForChild("SpeedRunTimerGui").Text)

Then it should print nil if there is no string value inside of the textlabel. This means that when it is printing the text value of the label is empty, so its printing nil. Also got to go to my next period now so for a couple minutes I might not respond

I used “tonumber” before it(30)

I’ll try it now with “tostring”

so, the change in output, 0:00:00.0 wrote.

so it works. Also you dont have to put tostring before it because it automatically will print the string. Also it must be something with the tonumber because if its printing nil somethings wrong.
Here is a link to using tostring and tonumber that you can read and hopefully get a little more information on why its not working because I don’t know.

1 Like

I have an idea why. Because tonumber only works if every part of the string is a number, putting the colons breaks it and makes it print nil. You are going to have to find some way to make it so that the actual time values are printed in between them by using I think this

print(firsttime .. ":" .. secondtime .. ":" .. thirdtime .. "." .. lasttime

I don’t know if its necessary for the decimal to have it around it but I guess that you could use some approach similar to this for changing the text or something. You may be able to make a second text label that holds those characters that you layer over it to make it so that it looks the same.

Okay, I’ll find other approaches to do this. Have a nice day!