Humanoid.Died not firing

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?

Death effect number 1 (lightning) has a bunch of prints because i originally thought that it was the problem.

Try adding local variables that grabs the humanoid but server sided. There should be a solution towards finding it through server.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
1 Like

A local script or a server script?

Ah, try changing it to a local script, and calling those variables I mentioned above. StarterScripts usually use local scripts rather then server scripts.

1 Like

Problem is, i want the death effects to be visible to all players, not only the player that died.

Try using a remote event that triggers towards the server so that players can see the death effects.

1 Like

So i get the player with the local script, then i fire to the server with that info?

Yeah get the humanoid from local scripts and once math.random selects a number from 1-3 fire the client and add a server script in serverscriptservice and if it selected 2 it shows the death effect number 2 which was selected from math.random I’m the local script.

I’m on my iPad so it’s hard to type with perfect grammar

1 Like

Going to try it out, i took long to respond since i was doing some personal stuff.

1 Like

Alright, just tried it out, it worked very well! Thanks for the help!

1 Like