local Humanoid = script.Parent
local HumanoidRootPart = script.Parent.Parent.HumanoidRootPart
local function Respawn()
if Humanoid.Health == 0 then
wait(15)
print("Respawning")
script.Parent.Parent.Crystal.Transparency = 0
Humanoid.Health = 100
Humanoid.MaxHealth = 100
end
end
local function Death()
if Humanoid.Health == 100 then return end
if Humanoid.Health <= 0 then
spawn(function()
print("Died")
script.Parent.Parent.Crystal.Transparency = 1
local Shatter = script.Shatter:Clone()
Shatter.Parent = HumanoidRootPart
Shatter.Pitch = 1.15 * (math.random(90, 110) / 100)
Shatter:Play()
game.Debris:AddItem(Shatter,1.5)
--wait(15)
--print("Should be showing")
--script.Parent.Parent.Crystal.Transparency = 0
--Humanoid.Health = 100
--Humanoid.MaxHealth = 100
end)
end
end
local function Hit()
if Humanoid.Health == 0 then return end
if Humanoid.Health > 0 then
print("Still ALive")
local Glass = script.Glass:Clone()
Glass.Parent = HumanoidRootPart
Glass.Pitch = 1.15 * (math.random(90, 110) / 100)
Glass:Play()
game.Debris:AddItem(Glass,1.5)
end
end
Humanoid.HealthChanged:connect(Hit)
Humanoid.HealthChanged:connect(Death)
Humanoid.HealthChanged:connect(Respawn)
Is there a better way to script this? I’m also using a serverscript I want to use a local script.