I have a morph system in a game that works by making the player transparent and welding a model to the humanoid.rootpart. This function AlignMorphOnPlayer purpose is to return a cframe aligning the morph on the players character so that it can be welded.
The issue is each morph is a different size and I am having trouble with some morphs floating slightly and others lower than the ground. Some look perfect. I have tried to approach it different ways and still come up with the same result. I have search the forums, the web and even tried to have AI help.
My hopes are someone here can point me in the right direction.
TIA
local function AlignMorphOnPlayerME(character:model, morph:model)
local _, size = character:GetBoundingBox()
local _, size2 = morph:GetBoundingBox()
local YDiff = size.Y - size2.Y
local newPosition = Vector3.new(
character.PrimaryPart.CFrame.Position.X,
character.PrimaryPart.Position.Y - (YDiff / 2),
character.PrimaryPart.CFrame.Position.Z
)
local _, orientation, _ = character.PrimaryPart.CFrame:ToOrientation()
local newCFrame = CFrame.new(newPosition) * CFrame.Angles(0, orientation, 0)
return newCFrame
end