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

How to make a custom health GUI?

Asked by 10 years ago

I tried this but it doesn't work, only works in solo mode in studio. I tried it online, it gives me no errors either. And it's in a local script in the Starterpack

local player = script.Parent.Parent.Parent.Parent.Parent.Parent
local char = player.Character
while true do
    local humanoid = char:FindFirstChild("Humanoid")
    if humanoid ~= nil then
        local bar = script.Parent
        bar.Size = UDim2.new(- humanoid.Health*-0.006, 0, 0.2, 0)  ---Multiplyed it by .006 since total length is .6 and the player has 100 health points.
    end
    wait()
end

1 answer

Log in to vote
0
Answered by 10 years ago

Try changing

local player = script.Parent.Parent.Parent.Parent.Parent.Parent

to

local player = game.Players.LocalPlayer

You said it's in a LocalScript and this only works in local scripts.

Also, try adding 'wait(3)' at the very top of the script.

0
I tried those, the parenting is right. Idk why it didn't work, but I figured it out. Thanks. Orlando777 315 — 10y
Ad

Answer this question