Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

All healthbar scripts being buggy and wont work?

Every healthbar script i try works fine for the most part, but when i die it doesnt go back to full size when i respawn. It's gotten to the point where im just looking at scripts online and they all still do that

this is the current script im using

-- ScriptGuider
-- Basic custom health bar program from my YouTube video
-- Video: https://www.youtube.com/watch?v=opZtUhwDWE8
wait() -- ROBLOX made me do this.

local Player = game:GetService'Players'.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Human = Character:WaitForChild("Humanoid")

local HealthFrame = script.Parent

Human.HealthChanged:connect(function(Health)
	HealthFrame.Size = UDim2.new(Health/Human.MaxHealth,0,1,0)
end)

2 comments

0

although i am new at scripting, maybe you should try to reset the health bar when the humanoid is dead, it could go into StarterCharacterScripts, although im not sure if it will work

0

believe it or not this worked

1 answer

it seems that you set the screengui ResetOnSpawn to false that makes the script stop working, try to put the character inside a loop like this or you can set it to true instead

local HealthFrame = script.Parent
local Player = game.Players.LocalPlayer

while wait(0.2) do
	local Character = Player.Character or Player.CharacterAdded:wait()
	local Human = Character:FindFirstChild("Humanoid")
	if Human then
		local Health = Human.Health
		HealthFrame.Size = UDim2.new(Health/Human.MaxHealth,0,1,0)
	end
end

1 comment

0

You are right, i had it set not to reset on spawn because there is another part of the hud that needs to stay as it is after death and i always have the HUD in one screengui so i didnt realise

This discussion is preserved as it was. New answers, comments, and votes are closed.