Alright, this one should be easy(i really hope)
I suppose it should work like this:
If player’s health between 80 - 100 then make only this frame visible, if between 60-79 make only this frame visible, if between 30-59 make only another frame visible, if between 0-29 and so on
local hp = Humanoid.Health
if hp >= 80 then
-- make this frame visible
elseif hp >= 60 then
-- make this frame visible
elseif hp >= 30 then
-- make this frame visible
else -- 0 -> 29
-- make this frame visible
end
If only 1 frame can be visible at a time, then this is a good way in doing it, if multiple frames can be visible then prob just use a if statement for each hp check
If you want a system to where it will also disable the visiblity of other frames then something like this will be better
frame1.Visible = hp >= 80
frame2.Visible = hp >= 60 and hp < 80
frame3.Visible = hp >= 30 and hp < 60
frame4.Visible = hp < 30
Thank you . . . . . . . . . . . .
Although, how do I like, connect it to player?
Heres some old healthbar I have make sure to parent it to a Ui thing and and put it in a local script.
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local human = char:WaitForChild("Humanoid")
human.HealthChanged:Connect(function(Dmg)
local tweenservice = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local goals = {
Size = UDim2.new(Dmg / human.MaxHealth, 0, 1, 0)
}
local changemeter = tweenservice:Create(script.Parent, info, goals)
changemeter:Play()
if human.Health == 80 then
script.Parent.BackgroundColor3 = Color3.fromRGB(6, 147, 23)
end
if human.Health <= 50 then
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 200, 0)
end
if human.Health <= 30 then
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
end
if human.Health <= 25 then
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
end
end)
If you have any questions then say below.
You can also see this setup here:
Healthbar place test.rbxl (35.0 KB)
Nice, thank you, i’ll find a way to fuse these two
The thing works on it’s own. Have you tried it in the setup place?
Nono, your healthbar’s just not exactly what i need (read the question more carefully, i mean) but I can see how i can change it
Roblox has their own model for a custom healthbar Gui.
Made it, it works very nice, but it stops working after the player dies. Thoughts?
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local human = char:WaitForChild("Humanoid")
local hud = player.PlayerGui.Hud.ImageLabel
local fine = hud.fine
local fine2 = hud.fine2
local caution = hud.caution
local danger = hud.danger
for _,player in pairs(game.Players:GetPlayers()) do
human.HealthChanged:Connect(function(Dmg)
local hp = human.Health
fine.Visible = hp >= 80
fine2.Visible = hp >= 60 and hp < 80
caution.Visible = hp >= 30 and hp < 60
danger.Visible = hp < 30
end)
end
Simple. Go to the screengui the thing is in. And turn off reset on spawn.
Nice, thanks again . . . . . . . .
wait it doesn’t work… Dont do it,.
Oh, yeah, ur right, the frame always stays on “danger”, well, not always, after death of course
Can you try to add a repeat script?
Did that help with what you need?
Kinda embarrassing question, but how and where exactly? I tried to add repeat until false and error says exhausted allowed execution time
Send me a screenshot of your sidebar. But have the script you have showing on the side.
Sorry, I meant a screenshot your explorer. I have a brainfart.