Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to put a number value in a Text ?

Asked by
Vitou 65 Snack Break
9 years ago

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

Log in to vote
8
Answered by 9 years ago

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"

0
Thnks for the help ! Vitou 65 — 9y
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() Perci1 4988 — 9y
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. adark 5487 — 9y
0
Not in this case, but as for the original question, tostring() is the best option in most cases. Perci1 4988 — 9y
Ad
Log in to vote
-3
Answered by 9 years ago
HUD = script.Parent 
Hertz = HUD.Hertz
Hertz_Shower = HUD.HertzDisplayer.Hertz 
Hertz_Shower.Text = Hertz.Value.." Hertz"

Answer this question