The PlayerRemoving event fires only after the player's character is removed and the player's parent is set to null.
However, Player Instances also have an event called CharacterRemoving which you can use in conjunction with the PlayerAdded event to remove the tools from the player when they leave the game.
Also use :WaitForChild() to make sure that the Humanoid still exists.
Revised Server Script
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterRemoving:Connect(function(Character)
Character:WaitForChild("Humanoid"):UnequipTools()
print("ToolsUnequiped")
end)
end)
2 comments
The error is saying the character doesn't exist, and that's because you tried to reference it after the player has left (or technically is) leaving the game. I'm curious as to why you want to try and unequip a player's tool when they try to leave the game?
because when player leave while equipping the tool it doesn't save equipping tool, and saved another unequipping tools.