How to destroy a character as soon it dies?

of course, scripting is not my strong suit, and I wanted to ask if there was any specific lines of code that could contribute to what I am asking, I am not sure where to plug it in my script.

local players = game:GetService("Players")

local despawnTime = 300 

players.PlayerAdded:Connect(function(player) -- fires when player is added to game
	player.CharacterAppearanceLoaded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")

		humanoid.Died:Connect(function() 
			local Burnt = game.Workspace.Burnt:Clone()
			debris:AddItem(Burnt, despawnTime)

			Burnt.Name = "Burnt"
			Burnt:PivotTo(character:GetPivot())
			Burnt.Parent = workspace
		end)
	end)
end)

The issue?
so currently, the script spawns a “corpse” when the player dies, but I also want to make it so the players limbs arent visible (everyone knows that shattered effect when you die) when you die, so how do i go about this?

Uhm you could either use Player:LoadCharacter() directly when they die, or use Character:Destroy() when they die.

If you want the limbs to turn invisible over time, you can just loop through every child in Character, and tween it’s transparency. (Just check if it’s a basepart or accessory)

Set the respawn time in Players to 0.

That will surely work, if OP have not ticked off AutoCharacterLoading. I’m just too used to always have ticked it off.

Yea that seems to curate the intended effect, thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.