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