So this script is meant to use the value of an IntValue I created to decide how big or small the health bar I have created is (the healthbar is a gui, health is inside the localplayer)
this works, in fact, the script runs without errors. But it only changes the size of the gui once and that is to whatever i predetermine the health value to be before I run the game. Any reason for this? Am I calling for anything improperly/does something I call change locations post-player connection?
Here is my code, any help is appreciated:
local player=game.Players.LocalPlayer local health=player.Health.Value local mana=player.Mana.Value local character=player.Character local function changeHealth() local health_frame=script.Parent.Gui.Frame.healthFrame health_frame.Size = UDim2.new(0, health, 0, 20) print("Done") end while wait(.1) do changeHealth() end
Its because you define the 'health' variable at the beginning of the script, locking it in to whatever the value of health was at that moment. In order to fix this, you need to move the line
local health=player.Health.Value
inside your changeHealth function.