For some reason the function below runs multiple times after the character dies?
Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if Humanoid.Health == 0 then
Character.Head.face:Destroy()
local Blood = ReplicatedStorage.DeathFX.Blood:Clone()
local Skin = ReplicatedStorage.DeathFX.Skin:Clone()
Blood.Parent = Character.Torso
Skin.Parent = Character.Torso
Skin.Color = ColorSequence.new(Character.Torso.Color)
Blood:Emit(50)
Skin:Emit(10)
for i,limb in pairs(Character:GetChildren()) do
if limb:IsA("Accessory") then
limb:Destroy()
end
if limb:IsA("Part") and limb.Name ~= "HumanoidRootPart" then
limb.Transparency = 1
local duplicatelimb = limb:Clone()
duplicatelimb.Transparency = 0
duplicatelimb.CanCollide = true
duplicatelimb.Anchored = false
duplicatelimb.Color = colors[math.random(1,#colors)]
duplicatelimb.Parent = game.Workspace.FX
local velocity = Instance.new("BodyVelocity")
velocity.Velocity = Vector3.new(math.random(5,10),math.random(40,50),math.random(5,10))
velocity.P = math.random(20,30)
velocity.Parent = duplicatelimb
Debris:AddItem(velocity,0.1)
end
end
end
end)
local last = tick()
Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
local elasped = tick()-last
if Humanoid.Health == 0 and elapsed >= 1 then
last = tick()
Character.Head.face:Destroy()
local Blood = ReplicatedStorage.DeathFX.Blood:Clone()
local Skin = ReplicatedStorage.DeathFX.Skin:Clone()
Blood.Parent = Character.Torso
Skin.Parent = Character.Torso
Skin.Color = ColorSequence.new(Character.Torso.Color)
Blood:Emit(50)
Skin:Emit(10)
for i,limb in pairs(Character:GetChildren()) do
if limb:IsA("Accessory") then
limb:Destroy()
end
if limb:IsA("Part") and limb.Name ~= "HumanoidRootPart" then
limb.Transparency = 1
local duplicatelimb = limb:Clone()
duplicatelimb.Transparency = 0
duplicatelimb.CanCollide = true
duplicatelimb.Anchored = false
duplicatelimb.Color = colors[math.random(1,#colors)]
duplicatelimb.Parent = game.Workspace.FX
local velocity = Instance.new("BodyVelocity")
velocity.Velocity = Vector3.new(math.random(5,10),math.random(40,50),math.random(5,10))
velocity.P = math.random(20,30)
velocity.Parent = duplicatelimb
Debris:AddItem(velocity,0.1)
end
end
end
end)
PropertyChanged is not the best option for checking when a humanoid dies, you should use Humanoid.Died.
I modified your code and added a debounce so after it calls once it will mark the timestamp and when it calls again it will check if the elasped time is greater than 1.