This is a bit of a short one.
I have a script that concatenates the number value to my TextLabel. The problem is that the text doesn’t change in game, it only changes in the properties menu.
local ammo = script.Parent.Bullets.Value local gungui = script.Parent.GunGui local ammotext = gungui.OuterFrame.InnerFrame:WaitForChild(“ammob”) while true do ammotext.Text = (“Ammo: “)..ammo.Value
I have an external script that lowers the Bullets Value each time the player shoots the weapon.
Anybody know why this is happening?
Firstly, you did not put a end to the loop. And using while true loop in this case isn't suggested at all. You could try this script.
local ammo = script.Parent.Bullets.Value local gungui = script.Parent.GunGui local ammotext = gungui.OuterFrame.InnerFrame:WaitForChild(“ammob”) script.Parent.Bullets:GetPropertyChangedSignal("Value"):Connect() ammotext.Text = “Ammo: “.. tostring(ammo) -- You also took value already, so it should be ammo instead of ammo.Value end)
I assume ammo
variable is NumberValue
or IntValue
. Now, the main problem with TextLabel
is that they don't put text if the text is a number
and not a string
.
To fix it, you can do :
ammotext.Text = "Ammo: "..tostring(ammo.Value)
We used tostring
that converts any numerical format is string
. The simple difference between a string
and a number
is :
String is "12345"
and Number is 12345
.
Lemme know if it helps!
EDIT : I checked in Studio by replicating your code, and you are using '` ``' instead of '" "'.