This is a serverscript inside Workspace. When I die, the particleemitter leaves, I know why, but I don't know how to fix it.
game.Players.PlayerAdded:connect(function(player)
repeat wait() until player.Character
local torso = player.Character:WaitForChild("Torso")
local newParticle = game.ServerStorage.ParticleEmitter:Clone()
newParticle.Parent = torso
local Humanoid = player.Character.Humanoid
Humanoid.HealthChanged:connect(function(NewHealth, player)
if NewHealth < 25 then --Checks the new health of the humanoid.
torso.ParticleEmitter.Enabled = true
else
torso.ParticleEmitter.Enabled = false
end
end)
end)

2 comments
I get this error (I made it a serverscript) 09:00:15.062 - Workspace.Script:2: attempt to index field 'Character' (a nil value)
Your script is correct but you need to wait for the humanoid in the character function. player.Character:WaitForChild("Humanoid").Died:connect(function(char)