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
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.
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)
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)