Script doesn't work for died humanoid

I made a script so that an aura would be given after death, but the cap does not give me an aura after death.

game.Players.PlayerAdded:Connect(function(player) 
	wait(1)  -- Wait for a moment to ensure everything is set up

	player.CharacterAdded:Connect(function(character)
		print("Add Aura")  -- Debug message for character spawn

		-- Check for leaderstats and Class
		if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Class") then
			local className = player.leaderstats.Class.Value
			print("Class Name: " .. className)  -- Debug output for the player's class

			-- Convert the class name, removing any dashes
			local auraClassName = className:gsub("-", "")  -- Replace dashes with an empty string
			print("Aura Class Name: " .. auraClassName)  -- Debug output for the aura class name

			local aura = game.ServerStorage.Powers.Auras:FindFirstChild(auraClassName)  -- Find the corresponding aura

			if aura then
				print("Aura found for class: " .. auraClassName)  -- Confirm aura was found
				local clonedAura = aura:Clone()  -- Clone the aura
				clonedAura.Parent = character  -- Set the parent to the character

				-- Attach aura parts to the character
				for _, part in pairs(clonedAura:GetChildren()) do
					if character:FindFirstChild(part.Name) then
						part.Parent = character[part.Name]  -- Parent part to the character's corresponding part
					else
						warn("Part " .. part.Name .. " not found in character.")  -- Warn if part is not found
					end
				end
			else
				warn("Aura for class " .. auraClassName .. " not found.")  -- Warn if aura is not found
			end
		else
			warn("Leaderstats or Class not found for player: " .. player.Name)  -- Warn if leaderstats or class is missing
		end
	end)
end)
1 Like

This is still relevant and I haven’t solved the problem

This is still relevant please help me solve it any help is appreciated

You can try setting the position of aura parts to the position of the character and that should work.

game.Players.PlayerAdded:Connect(function(player) 
	wait(1)  -- Wait for a moment to ensure everything is set up

	player.CharacterAdded:Connect(function(character)
		print("Add Aura")  -- Debug message for character spawn

		-- Check for leaderstats and Class
		if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Class") then
			local className = player.leaderstats.Class.Value
			print("Class Name: " .. className)  -- Debug output for the player's class

			-- Convert the class name, removing any dashes
			local auraClassName = className:gsub("-", "")  -- Replace dashes with an empty string
			print("Aura Class Name: " .. auraClassName)  -- Debug output for the aura class name

			local aura = game.ServerStorage.Powers.Auras:FindFirstChild(auraClassName)  -- Find the corresponding aura

			if aura then
				print("Aura found for class: " .. auraClassName)  -- Confirm aura was found
				local clonedAura = aura:Clone()  -- Clone the aura
				clonedAura.Parent = character  -- Set the parent to the character

				-- Attach aura parts to the character
				for _, part in pairs(clonedAura:GetChildren()) do
					if character:FindFirstChild(part.Name) then
						part.Parent = character[part.Name]  -- Parent part to the character's corresponding part
                        part.Position = character[part.Name].Position

					else
						warn("Part " .. part.Name .. " not found in character.")  -- Warn if part is not found
					end
				end
			else
				warn("Aura for class " .. auraClassName .. " not found.")  -- Warn if aura is not found
			end
		else
			warn("Leaderstats or Class not found for player: " .. player.Name)  -- Warn if leaderstats or class is missing
		end
	end)
end)

It didn’t help and I still don’t get the aura after the player dies

Please share the output of the code.

Position is not a valid member of ParticleEmitter “Lamino961.Head.Head”

This is still relevant I don’t know how to fix it

The error you are getting is because a particle emitter doesnt have a position, its position is locked to the part in which is place, so when you are calling part.Position which part being a particle emitter you arent doing nothing. I suggest you to instead of setting the position to the character, just directly insert the particle emitter to it.

is your aura a model? why does it need to be inside the model of the player? is it welded properly to something?

I made this script based on this video

This is still relevant and I haven’t solved the problem.

I still don’t understand how to fix this, help me

For debugging purposes try parenting the Particle Emitter to some part in the workspace and see if it is emitting particles. If it is not emitting particles then you may want to check if the Particle Emitter is enabled and also you might have to try changing some of the settings of the particle emitter.

Thanks for the answer, I appreciate it, I’ve already figured it out and fixed the script.