New Player Character Moving to Origin

I’m using a morph function I wrote to replace the player’s character with a new model. The player humanoid’s “dead” state is also disabled. Whenever the body is replaced, the new character will run to the origin (0,0,0) unless interrupted by the player. What would be a good way to stop this?

function morph(player,target)
	local newbody = game.ServerStorage.Morphs:findFirstChild(target):clone()
	newbody.Name = player.Name
	local originalbody = player.Character
	player.Character = newbody
	local data = DataManager[player]
	if data then
		data.Data.currentcharacter = target
	end
	local cf = originalbody.HumanoidRootPart.CFrame
	local hum
	for i,v in pairs(originalbody:GetChildren()) do
		if v:IsA("Humanoid") then
			v.Parent = newbody
			hum = v
		else
			v:Destroy()
		end
	end
	originalbody:Destroy()
	newbody.HumanoidRootPart.CFrame = cf
	newbody.Parent = game.Workspace
	for i,v in pairs(game.StarterGui:GetChildren()) do
		v:clone().Parent = player.PlayerGui
	end
end

My guess would be to set the Humanoid’s MoveTo property to the HumanoidRootPart’s position.

You could use ContextActionService to disable their control of WASD.

It’s an issue with the Humanoid, not the player’s input. The humanoid’s taking it to move to the origin.

Doesn’t work, also did :Move(Vector3.new(0,0,0) and nothing.
@Pro_lano Disabling input would just make it uninterruptable and not solve the problem.

Was just a guess, was also suggesting not the Origin, but the Humanoid’s RootPart: :Move(Humanoid.Parent.PrimaryPart.Position)

:Move is different than :MoveTo in that it moves in the direction relative to the position of the HumanoidRootPart. Hypothetically, :Move(0,0,0) would cancel movement. Likewise :MoveTo(humanoidrootpart.Position) had no effect.

1 Like

This actually worked, but not with the original body’s humanoidrootpart position, for whatever reason. Works with the position of the newbody’s.

1 Like