Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make it so if a character dies, it removes something from Workspace?

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			print(player.Name .. " has died!")
		end)
	end)
end)

if the character dies, I want something in workspace removed for example (1player game):

if game.Players.name.humanoid.health = 0 then
game.Workspace.Example:Remove()
end

1 comment

0

Just put line 2 of your 2nd script after line 4 in the first script

1 answer

✓ Accepted answer

All you have to do is put it in the Died function.

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
           	workspace.Example:remove()
        end)
    end)
end)

1 comment

0

Remove() is deprecated; you should use Destroy().

This discussion is preserved as it was. New answers, comments, and votes are closed.