Advertisement
4zx16

Morph Remade V2

Jun 30th, 2022 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.15 KB | Source Code | 0 0
  1. --[[
  2.  || 📜 AUTHOR: @4zx16 || Morph Remade V2
  3. ]]
  4. local function Create_Morph(hit)   
  5. --[[
  6. ---------------------------------------------------------------------
  7.               FINDFIRSTCHILD / VARIABLES:
  8. ----------------------------------------------------------------------
  9. --]]
  10.     local Humanoid = hit.Parent:FindFirstChild("Humanoid")
  11.     local Arm1 = hit.Parent:FindFirstChild("Arm1")
  12.     local Arm2 = hit.Parent:FindFirstChild("Arm2")
  13.     local Leg1 = hit.Parent:FindFirstChild("Leg1")
  14.     local Leg2 = hit.Parent:FindFirstChild("Leg2")
  15.     local Torso = hit.Parent:FindFirstChild("Chest")
  16.     local Head = hit.Parent:FindFirstChild("xHead")
  17. --[[
  18. ---------------------------------------------------------------------
  19.                   USER BODY PARTS:
  20. ----------------------------------------------------------------------
  21. --]]
  22.     local PLR_Head = hit.Parent:FindFirstChild("Head")
  23.     local PLR_Torso = hit.Parent:FindFirstChild("Torso")
  24.     local PLR_Left_Arm = hit.Parent:FindFirstChild("Left Arm")
  25.     local PLR_Right_Arm = hit.Parent:FindFirstChild("Right Arm")
  26.     local PLR_Left_Leg = hit.Parent:FindFirstChild("Left Leg")
  27.     local PLR_Right_Leg = hit.Parent:FindFirstChild("Right Leg")
  28.     local PLR_Right_Arm = hit.Parent:FindFirstChild("Right Arm")
  29.     local User = hit.Parent:GetChildren()
  30. --[[
  31. ---------------------------------------------------------------------
  32.                       ACTUAL FUNCTIONS:
  33. ----------------------------------------------------------------------
  34. --]]
  35.     if Humanoid ~= nil and Arm1 == nil then
  36.         local g = script.Parent.Parent.Arm1:Clone()
  37.         local C = g:GetChildren()
  38.         g.Parent = hit.Parent
  39.  
  40.         for i=1, #C do
  41.             if C[i].className == "Part" or C[i].className == "UnionOperation" then
  42.                 local W = Instance.new("Weld")
  43.                 W.Part0 = g.Middle
  44.                 W.Part1 = C[i]
  45.                 local CJ = CFrame.new(g.Middle.Position)
  46.                 local C0 = g.Middle.CFrame:inverse()*CJ
  47.                 local C1 = C[i].CFrame:inverse()*CJ
  48.                 W.C0 = C0
  49.                 W.C1 = C1
  50.                 W.Parent = g.Middle
  51.             end
  52.             local Y = Instance.new("Weld")
  53.             Y.Part0 = hit.Parent["Left Arm"]
  54.             Y.Part1 = g.Middle
  55.             Y.C0 = CFrame.new(0, 0, 0)
  56.             Y.Parent = Y.Part0
  57.         end
  58.         local h = g:GetChildren()
  59.         for i = 1, # h do
  60.             if h[i].className == "Part" or C[i].className == "UnionOperation" then
  61.                 h[i].Anchored = false
  62.                 h[i].CanCollide = false
  63.             end
  64.         end
  65.     end
  66.     if Humanoid ~= nil and Arm2 == nil then
  67.         local g = script.Parent.Parent.Arm2:Clone()
  68.         local C = g:GetChildren()
  69.         g.Parent = hit.Parent
  70.  
  71.         for i=1, #C do
  72.             if C[i].className == "Part" or C[i].className == "UnionOperation" then
  73.                 local W = Instance.new("Weld")
  74.                 W.Part0 = g.Middle
  75.                 W.Part1 = C[i]
  76.                 local CJ = CFrame.new(g.Middle.Position)
  77.                 local C0 = g.Middle.CFrame:inverse()*CJ
  78.                 local C1 = C[i].CFrame:inverse()*CJ
  79.                 W.C0 = C0
  80.                 W.C1 = C1
  81.                 W.Parent = g.Middle
  82.             end
  83.             local Y = Instance.new("Weld")
  84.             Y.Part0 = hit.Parent["Right Arm"]
  85.             Y.Part1 = g.Middle
  86.             Y.C0 = CFrame.new(0, 0, 0)
  87.             Y.Parent = Y.Part0
  88.         end
  89.         local h = g:GetChildren()
  90.         for i = 1, # h do
  91.             if h[i].className == "Part" or C[i].className == "UnionOperation" then
  92.                 h[i].Anchored = false
  93.                 h[i].CanCollide = false
  94.             end
  95.         end
  96.     end
  97.     if Humanoid ~= nil and Leg1 == nil then
  98.         local g = script.Parent.Parent.Leg1:Clone()
  99.         local C = g:GetChildren()
  100.         g.Parent = hit.Parent
  101.  
  102.         for i=1, #C do
  103.             if C[i].className == "Part" or C[i].className == "UnionOperation" then
  104.                 local W = Instance.new("Weld")
  105.                 W.Part0 = g.Middle
  106.                 W.Part1 = C[i]
  107.                 local CJ = CFrame.new(g.Middle.Position)
  108.                 local C0 = g.Middle.CFrame:inverse()*CJ
  109.                 local C1 = C[i].CFrame:inverse()*CJ
  110.                 W.C0 = C0
  111.                 W.C1 = C1
  112.                 W.Parent = g.Middle
  113.             end
  114.             local Y = Instance.new("Weld")
  115.             Y.Part0 = hit.Parent["Left Leg"]
  116.             Y.Part1 = g.Middle
  117.             Y.C0 = CFrame.new(0, 0, 0)
  118.             Y.Parent = Y.Part0
  119.         end
  120.         local h = g:GetChildren()
  121.         for i = 1, # h do
  122.             if h[i].className == "Part" or C[i].className == "UnionOperation" then
  123.                 h[i].Anchored = false
  124.                 h[i].CanCollide = false
  125.             end
  126.         end
  127.     end
  128.     if Humanoid ~= nil and Leg2 == nil then
  129.         local g = script.Parent.Parent.Leg2:Clone()
  130.         local C = g:GetChildren()
  131.         g.Parent = hit.Parent
  132.  
  133.         for i=1, #C do
  134.             if C[i].className == "Part" or C[i].className == "UnionOperation" then
  135.                 local W = Instance.new("Weld")
  136.                 W.Part0 = g.Middle
  137.                 W.Part1 = C[i]
  138.                 local CJ = CFrame.new(g.Middle.Position)
  139.                 local C0 = g.Middle.CFrame:inverse()*CJ
  140.                 local C1 = C[i].CFrame:inverse()*CJ
  141.                 W.C0 = C0
  142.                 W.C1 = C1
  143.                 W.Parent = g.Middle
  144.             end
  145.             local Y = Instance.new("Weld")
  146.             Y.Part0 = hit.Parent["Right Leg"]
  147.             Y.Part1 = g.Middle
  148.             Y.C0 = CFrame.new(0, 0, 0)
  149.             Y.Parent = Y.Part0
  150.         end
  151.         local h = g:GetChildren()
  152.         for i = 1, # h do
  153.             if h[i].className == "Part" or C[i].className == "UnionOperation" then
  154.                 h[i].Anchored = false
  155.                 h[i].CanCollide = false
  156.             end
  157.         end
  158.     end
  159.     if Humanoid ~= nil and Head == nil then
  160.         local g = script.Parent.Parent.xHead:Clone()
  161.         local C = g:GetChildren()
  162.         g.Parent = hit.Parent
  163.  
  164.         for i=1, #C do
  165.             if C[i].className == "Part" or C[i].className == "UnionOperation" then
  166.                 local W = Instance.new("Weld")
  167.                 W.Part0 = g.Middle
  168.                 W.Part1 = C[i]
  169.                 local CJ = CFrame.new(g.Middle.Position)
  170.                 local C0 = g.Middle.CFrame:inverse()*CJ
  171.                 local C1 = C[i].CFrame:inverse()*CJ
  172.                 W.C0 = C0
  173.                 W.C1 = C1
  174.                 W.Parent = g.Middle
  175.             end
  176.             local Y = Instance.new("Weld")
  177.             Y.Part0 = hit.Parent["Head"]
  178.             Y.Part1 = g.Middle
  179.             Y.C0 = CFrame.new(0, 0, 0)
  180.             Y.Parent = Y.Part0
  181.         end
  182.         local h = g:GetChildren()
  183.         for i = 1, # h do
  184.             if h[i].className == "Part" or C[i].className == "UnionOperation" then
  185.                 h[i].Anchored = false
  186.                 h[i].CanCollide = false
  187.             end
  188.         end
  189.     end
  190.     if Humanoid ~= nil and Torso == nil then
  191.         local g = script.Parent.Parent.Chest:Clone()
  192.         local C = g:GetChildren()
  193.         g.Parent = hit.Parent
  194.  
  195.         for i=1, #C do
  196.             if C[i].className == "Part" or C[i].className == "UnionOperation" then
  197.                 local W = Instance.new("Weld")
  198.                 W.Part0 = g.Middle
  199.                 W.Part1 = C[i]
  200.                 local CJ = CFrame.new(g.Middle.Position)
  201.                 local C0 = g.Middle.CFrame:inverse()*CJ
  202.                 local C1 = C[i].CFrame:inverse()*CJ
  203.                 W.C0 = C0
  204.                 W.C1 = C1
  205.                 W.Parent = g.Middle
  206.             end
  207.             local Y = Instance.new("Weld")
  208.             Y.Part0 = hit.Parent.Torso
  209.             Y.Part1 = g.Middle
  210.             Y.C0 = CFrame.new(0, 0, 0)
  211.             Y.Parent = Y.Part0
  212.         end
  213.         local h = g:GetChildren()
  214.         for i = 1, # h do
  215.             if h[i].className == "Part" or C[i].className == "UnionOperation" then
  216.                 h[i].Anchored = false
  217.                 h[i].CanCollide = false
  218.             end
  219.         end
  220.         if Humanoid ~= nil then
  221.             if hit.Parent:FindFirstChild("Head"):FindFirstChild("face").Texture == nil then return end
  222.             hit.Parent:FindFirstChild("Head"):FindFirstChild("face").Texture = 0
  223.         end
  224.     end
  225.     for i = 1, #User do
  226.         if User[i].className == "Accessory" then
  227.             User[i]:remove()
  228.         end
  229.         PLR_Head.Transparency = 0.98
  230.         PLR_Torso.Transparency = 1
  231.         PLR_Left_Arm.Transparency = 1
  232.         PLR_Right_Arm.Transparency = 1
  233.         PLR_Left_Leg.CanCollide = true
  234.         PLR_Left_Leg.Transparency = 1
  235.         PLR_Right_Leg.CanCollide = true
  236.         PLR_Right_Leg.Transparency = 1
  237.     end
  238. end
  239. script.Parent.Touched:Connect(Create_Morph)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement