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
01 | local player = script.Parent.Parent.Parent.Parent.Parent.Parent |
02 | local char = player.Character |
03 | while true do |
04 | local humanoid = char:FindFirstChild( "Humanoid" ) |
05 | if humanoid ~ = nil then |
06 | local bar = script.Parent |
07 | bar.Size = UDim 2. 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. |
08 | end |
09 | wait() |
10 | end |
Try changing
1 | local player = script.Parent.Parent.Parent.Parent.Parent.Parent |
to
1 | 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.