recently i have tried to create morphs, i made it so that they all had the same function to their own things and such, but something really strange happens
character vanishes, unable to move and stuff
this is the script
local CharacterModels = workspace:WaitForChild("CharacterModels")
local function MorphInto(Morph: Model, Player: Player)
local oldChar = Player.Character
if not oldChar then return end
local oldRoot = oldChar:FindFirstChild("HumanoidRootPart")
local oldCFrame = oldRoot and oldRoot.CFrame
local MorphClone = Morph:Clone()
MorphClone.Name = Player.Name
MorphClone.Parent = workspace
Player.Character = MorphClone
local newRoot = MorphClone:FindFirstChild("HumanoidRootPart")
if newRoot and oldCFrame then
newRoot.CFrame = oldCFrame
end
end
for _, v in ipairs(CharacterModels:GetChildren()) do
local Morph = v:FindFirstChild("Morph")
local torso = Morph and Morph:FindFirstChild("UpperTorso")
local Prompt = torso and torso:FindFirstChildOfClass("ProximityPrompt")
if Prompt then
Prompt.Triggered:Connect(function(Player)
MorphInto(Morph, Player)
end)
end
end
the morph has an animate script, humanoid, humanoidrootpart
The vanishing and freezing usually happens because when you swap Player.Character, Roblox dosent automatically give your new model everything it needs to function as a character.
Make sure the morph model is rigged exactly like an R15 character!! That means it needs all the standard body parts (UpperTorso, LowerTorso, Head, etc.), a Humanoid and a HumanoidRootPart. If even one required part is missing or misnamed the player will spawn broken.
You also need the Animate script inside the new model. Without that, the character wont play animations and sometimes wont move!!!
Set the PrimaryPart of the morph model to the HumanoidRootPart before you assign it as the character. (Otherwise positioning can fail)
local function MorphInto(Morph: Model, Player: Player)
local oldChar = Player.Character
if not oldChar then return end
local oldRoot = oldChar:FindFirstChild("HumanoidRootPart")
local oldCFrame = oldRoot and oldRoot.CFrame
local MorphClone = Morph:Clone()
MorphClone.Name = Player.Name
MorphClone.PrimaryPart = MorphClone:FindFirstChild("HumanoidRootPart")
MorphClone.Parent = workspace
-- make sure the Animate script is there
if not MorphClone:FindFirstChild("Animate") then
local animate = game.StarterPlayer.StarterCharacterScripts:FindFirstChild("Animate")
if animate then
animate:Clone().Parent = MorphClone
end
end
Player.Character = MorphClone
local newRoot = MorphClone:FindFirstChild("HumanoidRootPart")
if newRoot and oldCFrame then
newRoot.CFrame = oldCFrame
end
end
Also its usually a good idea to destroy the old character once you morph, otherwise you can end up with extra parts floating around.