Free character Morph Script

A nice little function that lets you morph into any character :slight_smile:
takes in 2 parameters, the Player and the model you want the player to morph into. I added in a functionality that gets all the scripts in the StarterCharacterScripts and places them back into the model. Let me know if there’s anything wrong with the code!

local StarterCharacterScripts = game:GetService("StarterPlayer").StarterCharacterScripts
local function doMorph(Player, morphModel)
	local oldCharacter = Player.Character
	local newCharacter = morphModel:Clone()
	
	newCharacter.HumanoidRootPart.Anchored = false
	newCharacter:PivotTo(oldCharacter.PrimaryPart.CFrame)
	Player.Character = newCharacter
	newCharacter.Parent = workspace
	
	oldCharacter:Destroy()
	for i, charScript in pairs(StarterCharacterScripts:GetChildren()) do
		local charScriptClone = charScript:Clone()
		charScriptClone.Parent = newCharacter
	end
	
end

UPDATED VERSION:

10 Likes

My bad guys. I discovered a bug where if you are in CameraType.Scriptable, then morph and go back to Enum.CameraType.Custom the camera breaks

1 Like

Solved the problem!
if you are trying to change from a different cam type to CameraType.Custom do this:

cam.CameraSubject = LocalPlayer.Character.Humanoid
cam.CameraType = Enum.CameraType.Custom

small error, :SetPrimaryPartCFrame() is now :PivotTo()

Can you send me the error message? I tried both :SetPrimaryPartCframe() and :PivotTo() and they seem to work fine…

also SetPrimaryPartCframe is deprecated I would use MoveTo() instead:

Found another camera bug, if I try an morph while my cameraType is in scriptable the position changes, looking into it

my bad, i meant small mistake, since :SetPrimaryPartCframe() is deprecated.

1 Like

ohhhh thats what you mean, thanks i’ll update the code now :sweat_smile:

1 Like

So this is my fix, I created a remote event and fire it to the player that’s being morphed. And then on the client side I just update the cam back to what its originally supposed to be.

SERVER SIDE

-- SERVER SIDE
local morphedCamClient = Events:WaitForChild("morphedCamClient") -- replace with your remote event 

local function doMorph(Player, morphModel)
	local oldCharacter = Player.Character
	local newCharacter = morphModel:Clone()
	
	newCharacter.HumanoidRootPart.Anchored = false
	newCharacter:PivotTo(oldCharacter.PrimaryPart.CFrame)
	Player.Character = newCharacter
	newCharacter.Parent = workspace
	
	oldCharacter:Destroy()
	for i, charScript in pairs(StarterCharacterScripts:GetChildren()) do
		local charScriptClone = charScript:Clone()
		charScriptClone.Parent = newCharacter
	end
	morphedCamClient:FireClient(Player)
	
end

CLIENT SIDE

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local cam = workspace.Camera

Events:WaitForChild("morphedCamClient").OnClientEvent:Connect(function() -- replace with your own event

	repeat task.wait()
		
	until cam.CameraType == Enum.CameraType.Custom

	-- add in your own function that reconnects your camera


end)
4 Likes