Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to put a number value in a Text ?

Hello, I'd like to do a GUI which is showing the Hertz Value but it doesn't work. In the output windows, I can see :

10:37:00.551 - Players.Player.PlayerGui.HUD.Script:5: attempt to call global 'Hertz' (a number value) 10:37:00.552 - Stack Begin 10:37:00.552 - Script 'Players.Player.PlayerGui.HUD.Script', Line 5 10:37:00.552 - Stack End

Here is my script

HUD = script.Parent
Hertz = HUD.Hertz.Value
Hertz_Shower = HUD.HertzDisplayer.Hertz

Hertz_Shower.Text = ""..Hertz" Hertz"

2 answers

✓ Accepted answer

With variables, you can't just use v = v.Valuebecause variables cannot hold a value. Instead, you should make Hertz equal to just HUD.Hertz and call the value later on. In addition, you'd also need to concatenate after the value. This code below should do the trick.

HUD = script.Parent
Hertz = HUD.Hertz
Hertz_Shower = HUD.HertzDisplayer.Hertz

Hertz_Shower.Text = ""..Hertz.Value.." Hertz"

4 comments

0

Thnks for the help !

1

Variables can hold the value of a property, but the variable will not remain connected to the object, so when the property changes the variable won't. Also look into tostring()

0

@Perci; tostring is not necessary in this case, and would still require concatenation. @OP; The empty string concatenation before Hertz.Value is also unneccessary.

0

Not in this case, but as for the original question, tostring() is the best option in most cases.

HUD = script.Parent 
Hertz = HUD.Hertz
Hertz_Shower = HUD.HertzDisplayer.Hertz 
Hertz_Shower.Text = Hertz.Value.." Hertz"

This discussion is preserved as it was. New answers, comments, and votes are closed.