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 get it for when something from the player gets removed it prints?

I was wondering how i would get something to print when something from the players character gets removed i.e Hats. I have tried using the changed event but it does not do it. Here is something i have tried.

game.Players.PlayerAdded:connect(function(player)
	game.Workspace:FindFirstChild(player.Name).Changed:connect(function(Chang)
		--Stuff
	end
end

1 answer

✓ Accepted answer

The Changed events only fires when an Object's properties change. To catch children being removed, use the DescendantRemoving event.

Additionally, your code will only catch changes on the player's first Character: it won't work if they respawn. To fix that, we use the CharacterAdded Event of Player objects:

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character.DescendantRemoving:connect(function(obj)
			print(obj.Name)
		end)
	end)
end)

1 comment

0

Thanks. :D

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