local ReplicatedStorage = game:GetService(“ReplicatedStorage”) local ServerStorage =…
- User
local ReplicatedStorage = game:GetService(“ReplicatedStorage”) local ServerStorage = game:GetService(“ServerStorage”)
local WELD_OFFSET = CFrame.new(0, 1, 0.5)
local function createWeldConstraint(part0, part1) assert(part0 and part1, “createWeldConstraint: Invalid parts”) local weld = Instance.new(“WeldConstraint”) weld.Part0 = part0 weld.Part1 = part1 weld.Parent = part0 end
local function createMotor6D(part0, part1, name, parent) assert(part0 and part1, “createMotor6D: Invalid parts”) local motor6D = Instance.new(“Motor6D”) motor6D.Part0 = part0 motor6D.Part1 = part1 motor6D.Name = name motor6D.C1 = WELD_OFFSET motor6D.Parent = parent or part0 end
local function weldAllParts(parentPart, primaryPart) assert(parentPart and primaryPart, “weldAllParts: Invalid parts”) for _, child in parentPart:GetChildren() do if child:IsA(“BasePart”) then createWeldConstraint(child, primaryPart) elseif child:IsA(“Model”) then if child.PrimaryPart then createWeldConstraint(child.PrimaryPart, primaryPart) end weldAllParts(child, child.PrimaryPart or primaryPart) end end end
local function calculateOffsets(parts, basePartName) local offsets = {} local basePart = parts[basePartName] if basePart and basePart.PrimaryPart then for _, part in parts do if part.PrimaryPart then offsets[part.Name] = part.PrimaryPart.Position - basePart.PrimaryPart.Position end end end return offsets end
local function setPartsCFrame(parts, torso, offsets) for name, part in parts do if part.PrimaryPart and offsets[name] then part:SetPrimaryPartCFrame(torso.CFrame * CFrame.new(offsets[name])) end end end
local function weldPartHierarchy(parts, torso, staticName) local offsets = calculateOffsets(parts, staticName) local staticPart = parts[staticName] if staticPart and staticPart.PrimaryPart then staticPart:SetPrimaryPartCFrame(torso.CFrame) createWeldConstraint(staticPart.PrimaryPart, torso) for name, part in parts do if name ~= staticName then local middlePart = part:FindFirstChild(“Middle”) local colorPart = part:FindFirstChild(“colorPartName”) if name == “Orbs” or name == “Rod” then if middlePart then for _, childPart in part:GetChildren() do if childPart:IsA(“BasePart”) and childPart ~= middlePart then createWeldConstraint(childPart, middlePart) end end end else if middlePart and colorPart then createWeldConstraint(colorPart, middlePart) createWeldConstraint(middlePart, staticPart.PrimaryPart) weldAllParts(part, middlePart) else weldAllParts(part, staticPart.PrimaryPart) end end end end setPartsCFrame(parts, torso, offsets) else warn(“Static part or its PrimaryPart is not set”) end end
local function handleMorph(morphTo, category, torso, Character) local function getMorphParts(morph) local parts = {} for _, partName in {“LowerL”, “LowerR”, “LowerStatic”, “UpperL”, “UpperR”, “UpperStatic”, “LowerStaticB”, “LowerStaticA”, “Orbs”, “Rod”} do parts[partName] = morph:FindFirstChild(partName) end return parts end
morphTo = ServerStorage.Morphs[category][morphTo] if morphTo then for _, folder in ServerStorage.Morphs[category]:GetChildren() do local existingFolder = Character:FindFirstChild(folder.Name) if existingFolder then existingFolder:Destroy() end end
- Assistant
- User
so technically i can delete the static parts, right?
- Assistant
Yes, based on the modifications you want to make, you can indeed delete the static parts (
LowerStatic,UpperStatic,LowerStaticB,LowerStaticA) from your morphing process since they will no longer be used in the script. The parts that were supposed to be welded to these static parts will now be welded directly to the player's torso.Just to reiterate, make sure you've performed the following:
- Modify the
weldPartHierarchyfunction to ignore the static parts and directly weld parts to the torso. - Adjust the
handleMorphfunction to no longer rely on static parts and callweldPartHierarchywithout those static parts. - Ensure that your morph definitions in the
ServerStorage.Morphsdo not require these static parts anymore.
With these steps completed, your script and morph setup should work as intended without the static parts.
If you have any static parts in your models or morphs within the
ServerStorage, you can safely remove them. Just be sure to test your script thoroughly to ensure it behaves as expected after these changes. - Modify the