I am trying to make a game with many morphs, and the morphs are all currently just made out of meshes. What is the best way to put the morph onto the character without having to go through each individual morph and welding each mesh to the player?
Here is my current script, but it is a pain because I had to go through each mesh and weld it to a rig which took forever. I also have a bunch of scripts and I don’t want paste all of them into the morphs.
The best method is probably to just make autowelding.
For example, you have 30 meshes, you want to connect some to the Head, some to LowerTorso, and the last one to RightFoot.
You put them all in one model, rename them so the script knows which mesh connects to which parts.
And when CharacterAdded is called, in your script you connect all the meshes to the morph’s parts.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
-- :: Wait for character to appear in workspace
task.wait()
-- :: Get character's CFrame
local Root = char:FindFirstChild("HumanoidRootPart")
local CFrameSpawned = Root.CFrame
-- :: Build your morph
local MorphCharacter = Model:Clone()
local MorphMeshesFolder = MorphCharacter:WaitForChild("Decorations")
for _, Decoration in pairs(MorphMeshesFolder :GetChildren()) do
local PartWeConnectTo = MorphCharacter:WaitForChild(Decoration.Name)
if PartWeConnectTo then
local Weld = Instance.new("Weld")
Weld.Part0 = PartWeConnectTo
Weld.Part1 = Decoration
Weld.C0 = CFrame.new()
Weld.C1 = Decoration.CFrame:toObjectSpace(PartWeConnectTo.CFrame)
Weld.Parent = PartWeConnectTo
end
end
-- :: Set morph to spawned position
MorphCharacter.HumanoidRootPart.CFrame = CFrameSpawned
plr.Character = MorphCharacter
char:Destroy()
MorphCharacter.Parent = workspace
end)
end)