I have this script for death effects in my game, but the Died
event won’t fire once the player dies.
Here is the script: (Is a Server Script and is inside StarterCharacterScripts
.)
local repstorage = game.ReplicatedStorage
local stuffs = repstorage.Other
local workstuff = workspace.Stuff
local tweenservice = game:GetService("TweenService")
print("deeed")
script.Parent.Humanoid.Died:Connect(function()
local random = math.random(1,3)
print(random)
if random == 1 then
local lightning = stuffs.LightningPart:Clone()
print("a")
local explosion = stuffs.LightningExplosion:Clone()
print("b")
lightning.Position = script.Parent.HumanoidRootPart.Position - Vector3.new(0,1,0)
print("c")
lightning.Size = Vector3.new(1,401,1)
print("d")
lightning.Parent = workstuff
print("e")
explosion.Position = script.Parent.HumanoidRootPart.Position - Vector3.new(0,1,0)
print("f")
explosion.Parent = workstuff
print("g")
elseif random == 2 then
local explosion = Instance.new("Explosion")
explosion.Position = script.Parent.HumanoidRootPart.Position
script.Parent:BreakJoints()
explosion.Parent = workstuff
elseif random == 3 then
script.Parent.HumanoidRootPart.Anchored = true
local avocado = stuffs.Avocado:Clone()
avocado.Position = script.Parent.HumanoidRootPart.Position + Vector3.new(0,75,0)
avocado.Parent = workspace
avocado.Sound:Play()
tweenservice:Create(avocado,TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Position = script.Parent.HumanoidRootPart.Position}):Play()
wait(1.75)
script.Parent:BreakJoints()
wait(1.25)
tweenservice:Create(avocado,TweenInfo.new(3,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Size = Vector3.new(0.01,0.01,0.01)}):Play()
wait(3)
avocado:Destroy()
end
end)
How can i fix it?