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 new character does exist and you are able to move it, but the camera subject doesn’t update when the player’s character is changed outside of :LoadCharacter(). A simple fix for the camera is something like this:
--// Put in StarterPlayerScripts
local function listenForCharacterChange()
game.Players.LocalPlayer:GetPropertyChangedSignal("Character"):Connect(function()
local newCharacter = game.Players.LocalPlayer.Character
if not newCharacter then
return
end
local humanoid = newCharacter:WaitForChild("Humanoid")
workspace.CurrentCamera.CameraSubject = humanoid
end)
end
listenForCharacterChange()
I’m not sure why the character’s CFrame doesn’t update properly, but this will at least solve the camera issue
the camera now works and is automatically focusing on the new morph model. My assumption is that because you parent the morph clone to workspace first BEFORE setting it to Player.Character, your code shows as if
TL;DR: Try setting the morph clone to Player.Character first before parenting it to workspace. Your code should work.
i put the models and the script you guys have provided me in a different game for better testing, now its doing nothing
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
Player.Character = MorphClone
MorphClone.Parent = workspace
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)
print("Triggered")
MorphInto(Morph, Player)
end)
end
end
--// Put in StarterPlayerScripts
local function listenForCharacterChange()
game.Players.LocalPlayer:GetPropertyChangedSignal("Character"):Connect(function()
local newCharacter = game.Players.LocalPlayer.Character
if not newCharacter then
return
end
local humanoid = newCharacter:WaitForChild("Humanoid")
workspace.CurrentCamera.CameraSubject = humanoid
end)
end
listenForCharacterChange()
should i perhaps just post the models here so that you guys can see it? it’ll be faster and you’ll be abl to see if something is wrong with the models rather then the script