What do you want to achieve? I want to fix my health bar, as I don’t want any bugs in my game.
What is the issue? It breaks after the first death.
What solutions have you tried so far? I’ve tried having it set the character every time it runs the while loop.
Here’s my script: ( local script )
while wait() do
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
local hum = char:WaitForChild("Humanoid")
print(hum.Parent)
script.Parent.Size = UDim2.new(0,((hum.Health / hum.MaxHealth) * 100) * 5,0.8,0)
end
end
oh,to load character manually,i will send you a code that will works if its.
Client:
task.wait(1)
local plr = script.Parent.Parent.Parent.Parent.Parent
local char = plr.Character or plr.CharacterAdded:Wait()
char.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if hum.Health <= 0 then
game:GetService("ReplicatedStorage").Respawn:FireServer()
end
local hum = char:WaitForChild("Humanoid")
print(hum.Parent)
script.Parent.Size = UDim2.new(0,((hum.Health / hum.MaxHealth) * 100) * 5,0.8,0)
end)
Server:
game:GetService("ReplicatedStorage").Respawn.OnServerEvent:Connect(function(Plr)
task.wait(3) --> your respawn time
Plr:LoadChararacter()
end)
You just need to add the server script to ServerScriptService.and then create a remote event named: “Respawn”.