UnionOperation not working in moprh?
I am trying to create a morph where you touch a button and belt morphs on you. I have tried to do this on my own but have failed miserably.
The button contains several scripts: Arms, Legs, PresentScript, Script, Torso
Before added this
01 | if C [ i ] .className = = "UnionOperation" then |
02 | local W = Instance.new( "Weld" ) |
05 | local CJ = CFrame.new(g.Middle.Position) |
06 | local C 0 = g.Middle.CFrame:inverse()*CJ |
07 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
The script worked but only gave me the morph that isn't a union. After when I added it the whole morph did not work. When I tested the morph with this my output stated:
Workspace.PoliceDutyBelt.Button.Legs:85: 'end' expected (to close 'if' at line 2) near '<eof>'
Workspace.PoliceDutyBelt.Button.Arms:85: 'end' expected (to close 'if' at line 2) near '<eof>'
Workspace.PoliceDutyBelt.Button.Torso:44: 'end' expected (to close 'function' at line 1) near '<eof>'
When I touched the part it said:
Delete is not a valid member of Part
Arms Script:
01 | function onTouched(hit) |
02 | if hit.Parent:findFirstChild( "Humanoid" ) ~ = nil and hit.Parent:findFirstChild( "Arm1" ) = = nil then |
03 | local g = script.Parent.Parent.Arm 1 :clone() |
05 | local C = g:GetChildren() |
07 | if C [ i ] .className = = "Part" then |
08 | local W = Instance.new( "Weld" ) |
11 | local CJ = CFrame.new(g.Middle.Position) |
12 | local C 0 = g.Middle.CFrame:inverse()*CJ |
13 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
17 | if C [ i ] .className = = "UnionOperation" then |
18 | local W = Instance.new( "Weld" ) |
21 | local CJ = CFrame.new(g.Middle.Position) |
22 | local C 0 = g.Middle.CFrame:inverse()*CJ |
23 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
28 | local Y = Instance.new( "Weld" ) |
29 | Y.Part 0 = hit.Parent [ "Left Arm" ] |
31 | Y.C 0 = CFrame.new( 0 , 0 , 0 ) |
35 | local h = g:GetChildren() |
38 | h [ i ] .CanCollide = false |
43 | if hit.Parent:findFirstChild( "Humanoid" ) ~ = nil and hit.Parent:findFirstChild( "Arm2" ) = = nil then |
44 | local g = script.Parent.Parent.Arm 2 :clone() |
46 | local C = g:GetChildren() |
48 | if C [ i ] .className = = "Part" then |
49 | local W = Instance.new( "Weld" ) |
52 | local CJ = CFrame.new(g.Middle.Position) |
53 | local C 0 = g.Middle.CFrame:inverse()*CJ |
54 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
58 | if C [ i ] .className = = "UnionOperation" then |
59 | local W = Instance.new( "Weld" ) |
62 | local CJ = CFrame.new(g.Middle.Position) |
63 | local C 0 = g.Middle.CFrame:inverse()*CJ |
64 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
69 | local Y = Instance.new( "Weld" ) |
70 | Y.Part 0 = hit.Parent [ "Right Arm" ] |
72 | Y.C 0 = CFrame.new( 0 , 0 , 0 ) |
76 | local h = g:GetChildren() |
79 | h [ i ] .CanCollide = false |
85 | script.Parent.Touched:connect(onTouched) |
Legs Script:
01 | function onTouched(hit) |
02 | if hit.Parent:findFirstChild( "Humanoid" ) ~ = nil and hit.Parent:findFirstChild( "Leg1" ) = = nil then |
03 | local g = script.Parent.Parent.Leg 1 :clone() |
05 | local C = g:GetChildren() |
07 | if C [ i ] .className = = "Part" then |
08 | local W = Instance.new( "Weld" ) |
11 | local CJ = CFrame.new(g.Middle.Position) |
12 | local C 0 = g.Middle.CFrame:inverse()*CJ |
13 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
17 | if C [ i ] .className = = "UnionOperation" then |
18 | local W = Instance.new( "Weld" ) |
21 | local CJ = CFrame.new(g.Middle.Position) |
22 | local C 0 = g.Middle.CFrame:inverse()*CJ |
23 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
28 | local Y = Instance.new( "Weld" ) |
29 | Y.Part 0 = hit.Parent [ "Left Leg" ] |
31 | Y.C 0 = CFrame.new( 0 , 0 , 0 ) |
35 | local h = g:GetChildren() |
38 | h [ i ] .CanCollide = false |
43 | if hit.Parent:findFirstChild( "Humanoid" ) ~ = nil and hit.Parent:findFirstChild( "Leg2" ) = = nil then |
44 | local g = script.Parent.Parent.Leg 2 :clone() |
46 | local C = g:GetChildren() |
48 | if C [ i ] .className = = "Part" then |
49 | local W = Instance.new( "Weld" ) |
52 | local CJ = CFrame.new(g.Middle.Position) |
53 | local C 0 = g.Middle.CFrame:inverse()*CJ |
54 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
58 | if C [ i ] .className = = "UnionOperation" then |
59 | local W = Instance.new( "Weld" ) |
62 | local CJ = CFrame.new(g.Middle.Position) |
63 | local C 0 = g.Middle.CFrame:inverse()*CJ |
64 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
69 | local Y = Instance.new( "Weld" ) |
70 | Y.Part 0 = hit.Parent [ "Right Leg" ] |
72 | Y.C 0 = CFrame.new( 0 , 0 , 0 ) |
76 | local h = g:GetChildren() |
79 | h [ i ] .CanCollide = false |
85 | script.Parent.Touched:connect(onTouched) |
PresentScript Script:
03 | function getPlayer(humanoid) |
04 | local players = game.Players:children() |
06 | if players [ i ] .Character.Humanoid = = humanoid then return players [ i ] end |
13 | local human = part.Parent:findFirstChild( "Humanoid" ) |
14 | if (human ~ = nil ) and debounce = = false then |
18 | local player = getPlayer(human) |
20 | if (player = = nil ) then return end |
22 | script.Parent.Delete:clone().Parent = player.Backpack |
23 | script.Parent.Grab:clone().Parent = player.Backpack |
24 | script.Parent.Copy:clone().Parent = player.Backpack |
25 | script.Parent.Rotate:clone().Parent = player.Backpack |
26 | script.Parent.Resize:clone().Parent = player.Backpack |
34 | script.Parent.Touched:connect(onTouch) |
Script Script:
1 | function onTouched(part) |
2 | local h = part.Parent.Parent:findFirstChild( "Humanoid" ) |
9 | script.Parent.Touched:connect(onTouched) |
Torso Script:
01 | function onTouched(hit) |
02 | if hit.Parent:findFirstChild( "Humanoid" ) ~ = nil and hit.Parent:findFirstChild( "Chest" ) = = nil then |
03 | local g = script.Parent.Parent.Chest:clone() |
05 | local C = g:GetChildren() |
07 | if C [ i ] .className = = "Part" then |
08 | local W = Instance.new( "Weld" ) |
11 | local CJ = CFrame.new(g.Middle.Position) |
12 | local C 0 = g.Middle.CFrame:inverse()*CJ |
13 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
17 | if C [ i ] .className = = "UnionOperation" then |
18 | local W = Instance.new( "Weld" ) |
21 | local CJ = CFrame.new(g.Middle.Position) |
22 | local C 0 = g.Middle.CFrame:inverse()*CJ |
23 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
28 | local Y = Instance.new( "Weld" ) |
29 | Y.Part 0 = hit.Parent.Torso |
31 | Y.C 0 = CFrame.new( 0 , 0 , 0 ) |
35 | local h = g:GetChildren() |
38 | h [ i ] .CanCollide = false |
44 | script.Parent.Touched:connect(onTouched) |
Please me help, thank you!