Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Frame isnt changing size/position?

Asked by
akito 0
4 years ago
Edited 4 years ago

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)

Answer this question