Hello I am trying to make a health gui and my frame isnt changing size or position, please help!
local Humanoid = script.Parent.Parent.Parent.Character:WaitForChild('Humanoid') local Health = Humanoid.Health local HPBar = script.Parent.Screen.HealthBar spawn(function() while wait() do HPBar.Position = UDim2.new(0.5, (Health * -5) / 2, 0.85, 0) HPBar.Size = UDim2.new(0, Health * 5, 0, 10) end end)
Edit: I have solved this! Problem was you need to put all the variables into the loop.
spawn(function() while wait() do local Humanoid = script.Parent.Parent.Parent.Character:WaitForChild('Humanoid') local Health = Humanoid.Health local HPBar = script.Parent.Screen.HealthBar HPBar.Position = UDim2.new(0.5, (Health * -5) / 2, 0.85, 0) HPBar.Size = UDim2.new(0, Health * 5, 0, 10) end end)