How to update a NumberValue?
Hello, I recently got stuck into a problem while scripting a BillboardGui for an NPC for my Roblox game, the NumberValue called "energy" inside the NPC doesn't update via scripts or manually via properties. I've tried switching to an IntValue however that didn't work too. This server script checks if "energy" NumberValue is smaller than 50 or 25 and then changes the NPC's WalkSpeed, and also sets a BillboardGui size.
01 | local energy = script.Parent.Parent.Parent.Parent.energy |
04 | energy.Value = script.Parent.Size.X.Scale * 100 |
05 | script.Parent.Size = UDim 2. new(energy.Value/ 100 , 0 , 0.03 , 0 ) |
06 | print ( "updated to " .. energy.Value/ 100 ) |
07 | if energy.Value > 95 then |
08 | script.Parent.Size = UDim 2. new( 0.95 , 0 , 0.03 , 0 ) |
11 | if energy.Value < 50 then |
12 | script.Parent.Parent.Parent.Parent.Humanoid.WalkSpeed = 14 |
15 | if energy.Value < 25 then |
16 | script.Parent.Parent.Parent.Parent.Humanoid.WalkSpeed = 10 |
As you can see in line 6, I made it so it prints the "energy" value, however, this prints every 0.1 seconds "updated to 0.94999998807907".