do -- pls work
local StatBars = script.Parent
local Health = StatBars.HealthContainer
local Humanoid = Character.Humanoid
--if Humanoid then
Health.HealthBarClip.Texture.Position = UDim2.new((Humanoid.Health / Humanoid.MaxHealth), 0, 0, 0)
Humanoid.HealthChanged:Connect(function ()
Health.HealthBarClip.Texture:TweenPosition(UDim2.new((Humanoid.Health / Humanoid.MaxHealth), 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, true)
end)
--end
end
No matter what I do - moving this script to the PlayerGui or a ResetOnSpawn true Gui, using prints, using WaitForChild - it just won’t work. I copy pasted this script into other maps and it works, but my one map is having this problem and it’s preventing me from launching. Why will my script not detect the Humanoid and act according to the script?
In all of these supposed problems, there has been NO errors in F9.
Exactly. That’s why you can’t do Player:WaitForChild(“Character”).
In fact, if Character was a child of Player, then repeat wait() until LocalPlayer.Character would error because Character doesn’t exist. That code works because Character is a property that is nil until the character exists.
An alternative:
local Character = Player.Character or Player.CharacterAdded:Wait()
or
if not Player.Character then
player.CharacterAdded:Wait()
end