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.
local energy = script.Parent.Parent.Parent.Parent.energy while wait(0.1) do energy.Value = script.Parent.Size.X.Scale * 100 script.Parent.Size = UDim2.new(energy.Value/100, 0, 0.03, 0) print("updated to " .. energy.Value/100) if energy.Value > 95 then script.Parent.Size = UDim2.new(0.95, 0, 0.03, 0) energy.Value = 95 end if energy.Value < 50 then script.Parent.Parent.Parent.Parent.Humanoid.WalkSpeed = 14 end if energy.Value < 25 then script.Parent.Parent.Parent.Parent.Humanoid.WalkSpeed = 10 end end
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".
Firstly, You're basically printing a number between 0 and 1 since you times by 100 initially and then divide by 100 in the print
Secondly, I do not see any code that would externally change the size of the UI, you're basically just continuously setting the size to the same value over and over again.