Video: https://youtu.be/eXRpUMYFNvA
Hello all, I recently made a morph script, but for some reason, the arm animation is odd, and when a gun is equipped, the arm enters a weird position. Code below for the morph.
Morph Code:
-- Scripted by ItzHiimnew for Prometheus Labs
local MorphName = "IA"
local MorphPath = game.ReplicatedStorage.Morphs.IA -- path to the morph
local ShirtId = "rbxassetid://338740550"
local PantsId = "rbxassetid://338750779"
-- done set up
local Debounce = false
script.Parent.Touched:Connect(function(hit)
if Debounce == false then
if hit.Parent:FindFirstChild("Humanoid") then
Debounce = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local clone = script.MorphGui:Clone()
clone.Shadow.LoadingText.Text = "Morphing into "..MorphName.."..."
clone.Parent = player.PlayerGui
clone.Shadow:TweenPosition(UDim2.new(0.404,0,0.782,0))
wait(1)
local WalkSpeed = humanoid.WalkSpeed
local JumpPower = humanoid.JumpPower
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
wait(2)
script.Parent.ParticleEmitter.Enabled = true
local characterCframe = hit.Parent:GetPrimaryPartCFrame()
local finalcframe = characterCframe
local mpclone = MorphPath:Clone()
mpclone.Parent = hit.Parent
mpclone:SetPrimaryPartCFrame(finalcframe)
-- torso creation
local PrimaryPart = hit.Parent.Torso
local characterTorsoCF = hit.Parent["Torso"].CFrame + Vector3.new(0, 0.2, 0)
mpclone.Chest:SetPrimaryPartCFrame(characterTorsoCF)
local Parts = mpclone.Chest:GetChildren()
for i = 1, #Parts do
local weld = Instance.new("Weld")
weld.Part0 = hit.Parent.Torso
weld.Part1 = Parts[i]
weld.C0 = PrimaryPart.CFrame:inverse()
weld.C1 = Parts[i].CFrame:inverse()
weld.Parent = Parts[i]
Parts[i].Anchored = false
end
-- arms creation
local characterLeftArmCF = hit.Parent["Left Arm"].CFrame
local PrimaryPart = hit.Parent["Left Arm"]
mpclone.Arm1:SetPrimaryPartCFrame(characterLeftArmCF)
local Parts = mpclone.Arm1:GetChildren()
for i = 1, #Parts do
local weld = Instance.new("Weld")
weld.Part0 = hit.Parent["Left Arm"]
weld.Part1 = Parts[i]
weld.C0 = PrimaryPart.CFrame:inverse()
weld.C1 = Parts[i].CFrame:inverse()
weld.Parent = Parts[i]
Parts[i].Anchored = false
end
local PrimaryPart = hit.Parent["Right Arm"]
local characterRightArmCF = hit.Parent["Right Arm"].CFrame
mpclone.Arm1:SetPrimaryPartCFrame(characterRightArmCF)
local Parts = mpclone.Arm1:GetChildren()
for i = 1, #Parts do
local weld = Instance.new("Weld")
weld.Part0 = hit.Parent["Right Arm"]
weld.Part1 = Parts[i]
weld.C0 = PrimaryPart.CFrame:inverse()
weld.C1 = Parts[i].CFrame:inverse()
weld.Parent = Parts[i]
Parts[i].Anchored = false
end
-- legs creation
local PrimaryPart = hit.Parent["Right Leg"]
local characterRightLegCF = hit.Parent["Right Leg"].CFrame
mpclone.Leg2:SetPrimaryPartCFrame(characterRightLegCF)
local Parts = mpclone.Leg2:GetChildren()
for i = 1, #Parts do
local weld = Instance.new("Weld")
weld.Part0 = hit.Parent["Right Leg"]
weld.Part1 = Parts[i]
weld.C0 = PrimaryPart.CFrame:inverse()
weld.C1 = Parts[i].CFrame:inverse()
weld.Parent = Parts[i]
Parts[i].Anchored = false
end
local PrimaryPart = hit.Parent["Left Leg"]
local characterLeftLegCF = hit.Parent["Left Leg"].CFrame
mpclone.Leg1:SetPrimaryPartCFrame(characterLeftLegCF)
local Parts = mpclone.Leg1:GetChildren()
for i = 1, #Parts do
local weld = Instance.new("Weld")
weld.Part0 = hit.Parent["Left Leg"]
weld.Part1 = Parts[i]
weld.C0 = PrimaryPart.CFrame:inverse()
weld.C1 = Parts[i].CFrame:inverse()
weld.Parent = Parts[i]
Parts[i].Anchored = false
end
-- head creation
local PrimaryPart = hit.Parent.Head
local characterHeadCF = hit.Parent["Head"].CFrame
mpclone.Hair:SetPrimaryPartCFrame(characterHeadCF)
local Parts = mpclone.Hair:GetChildren()
for i = 1, #Parts do
local weld = Instance.new("Weld")
weld.Part0 = hit.Parent.Head
weld.Part1 = Parts[i]
weld.C0 = PrimaryPart.CFrame:inverse()
weld.C1 = Parts[i].CFrame:inverse()
weld.Parent = Parts[i]
Parts[i].Anchored = false
end
-- remove clothes
for _, child in pairs(hit.Parent:GetChildren()) do
if child:IsA('Hat') then
print("removed hat")
child:Destroy()
end
if child:IsA('ShirtGraphic')then
print("removed shirt graphic")
child:Destroy()
end
if child:IsA('Shirt')then
print("removed shirt")
child:Destroy()
end
if child:IsA("BasePart")then
child.BrickColor = BrickColor.new("Really black")
end
if child:IsA("Accessory") then
child:Destroy()
end
end
-- add clothes
local shirt = Instance.new("Shirt")
shirt.ShirtTemplate = ShirtId
shirt.Parent = hit.Parent
local pants = Instance.new("Pants")
pants.PantsTemplate = PantsId
pants.Parent = hit.Parent
wait(2)
humanoid.WalkSpeed = WalkSpeed
humanoid.JumpPower = JumpPower
script.Parent.ParticleEmitter.Enabled = false
clone.Shadow.LoadingText.Visible = false
clone.Shadow.FinishedText.Visible = true
clone.Shadow.Loading.Visible = false
wait(3)
clone.Shadow:TweenPosition(UDim2.new(0.404,0,1,0))
wait(1)
clone:Destroy()
elseif hit.Parent.Parent:FindFirstChild("Humanoid") then
Debounce = true
end
Debounce = false
end
end)
Thanks in advance!
- ItzHiimnew
