A nice little function that lets you morph into any character
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
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)