Parenting character to nil then parenting it back to workspace causes it to move randomly

Hey, so when I parent the player’s character model to nil, then put it back into the workspace, it’ll randomly move in a direction even when I’m not pressing any buttons.

I’ve tried overriding anything the player control module is doing prior to parenting it to nil by using :Move(Vector3.new(0, 0, 0)) but that didn’t work.

Any ideas? Thanks :slight_smile:

edit

This is actually really stupid behavior. I’ve just tried explicitly disabling the player control module prior to parenting it to nil, and it still moves when re-parented.

Good job Roblox :slight_smile:

1 Like

This is pretty weird indeed. The character seems to run towards 0,0,0 when it’s parented back to workspace. A workaround I found was to just Humanoid:MoveTo to the last position before you parented the character to nil

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild'Humanoid'
		local RootPart = Character:WaitForChild'HumanoidRootPart'
		wait(5)
		local LastPosition = RootPart.Position
		Character.Parent = nil
		wait(3)
		Character.Parent = workspace
		Humanoid:MoveTo(LastPosition)
	end)
end)
1 Like

Thank you for that,

I’ve tried it though, and surprisingly nothing changed.

local oldPositions = {}

game.ReplicatedStorage.Events.HideCharacter.OnServerEvent:Connect(function(player, isCharacterShown)
	local char = player.Character
	
	if not isCharacterShown then
		oldPositions[player] = char.PrimaryPart.CFrame
		char.Parent = nil
	else
		char.Parent = workspace
		char.Humanoid:MoveTo(oldPositions[player])
	end
end)

MoveTo expects a Vector3, but you’re remembering the CFrame of the PrimaryPart. Other than that, seems to work fine for me.

1 Like

Ah, silly me.

Thank you! :slight_smile:

Hi, just updating you that this has been identified as a bug and Roblox is currently looking into it.
I referenced your thread as a prior report

1 Like