-- Listen for player's character events and create/destroy an associated OrientableBody

local function onPlayerEntered(player: Player)
	if player.Character then
		onCharacterAdded(player, player.Character)
	end

	characterAddedConnections[player] = player.CharacterAdded:Connect(function(character)
		onCharacterAdded(player, character)
	end)

	characterRemovingConnections[player] = player.CharacterRemoving:Connect(function()
		if orientableBodies[player] then
			orientableBodies[player]:destroy()
			orientableBodies[player] = nil
		end
	end)
end
