Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

UnionOperation not working in moprh?

Asked by 8 years ago

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

01if C[i].className == "UnionOperation" then
02                local W = Instance.new("Weld")
03                W.Part0 = g.Middle
04                W.Part1 = C[i]
05                local CJ = CFrame.new(g.Middle.Position)
06                local C0 = g.Middle.CFrame:inverse()*CJ
07                local C1 = C[i].CFrame:inverse()*CJ
08                W.C0 = C0
09                W.C1 = C1
10                W.Parent = g.Middle

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:

01function onTouched(hit)
02    if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Arm1") == nil then
03        local g = script.Parent.Parent.Arm1:clone()
04        g.Parent = hit.Parent
05        local C = g:GetChildren()
06        for i=1, #C do
07            if C[i].className == "Part" then
08                local W = Instance.new("Weld")
09                W.Part0 = g.Middle
10                W.Part1 = C[i]
11                local CJ = CFrame.new(g.Middle.Position)
12                local C0 = g.Middle.CFrame:inverse()*CJ
13                local C1 = C[i].CFrame:inverse()*CJ
14                W.C0 = C0
15                W.C1 = C1
View all 85 lines...

Legs Script:

01function onTouched(hit)
02    if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Leg1") == nil then
03        local g = script.Parent.Parent.Leg1:clone()
04        g.Parent = hit.Parent
05        local C = g:GetChildren()
06        for i=1, #C do
07            if C[i].className == "Part" then
08                local W = Instance.new("Weld")
09                W.Part0 = g.Middle
10                W.Part1 = C[i]
11                local CJ = CFrame.new(g.Middle.Position)
12                local C0 = g.Middle.CFrame:inverse()*CJ
13                local C1 = C[i].CFrame:inverse()*CJ
14                W.C0 = C0
15                W.C1 = C1
View all 85 lines...

PresentScript Script:

01local debounce = false
02 
03function getPlayer(humanoid)
04local players = game.Players:children()
05for i = 1, #players do
06if players[i].Character.Humanoid == humanoid then return players[i] end
07end
08return nil
09end
10 
11function onTouch(part)
12 
13local human = part.Parent:findFirstChild("Humanoid")
14if (human ~= nil) and debounce == false then
15 
View all 34 lines...

Script Script:

1function onTouched(part)
2 local h = part.Parent.Parent:findFirstChild("Humanoid")
3 if (h ~=nil) then -- If there is a Humanoid then
4       h.MaxHealth = 120
5       h.Health = 120
6 end
7 end
8 
9script.Parent.Touched:connect(onTouched)

Torso Script:

01function onTouched(hit)
02    if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Chest") == nil then
03        local g = script.Parent.Parent.Chest:clone()
04        g.Parent = hit.Parent
05        local C = g:GetChildren()
06        for i=1, #C do
07            if C[i].className == "Part" then
08                local W = Instance.new("Weld")
09                W.Part0 = g.Middle
10                W.Part1 = C[i]
11                local CJ = CFrame.new(g.Middle.Position)
12                local C0 = g.Middle.CFrame:inverse()*CJ
13                local C1 = C[i].CFrame:inverse()*CJ
14                W.C0 = C0
15                W.C1 = C1
View all 44 lines...

Please me help, thank you!

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

Your problem was just a little format error. All you needed to do was change any second if's to 'elseif' and then add 'end'. Try using this format as a diagram of what I am talking about:

1if value == 3 then
2--function
3elseif value == 2 then
4--function
5else
6--function
7end
0
I have found another answer and fixed it. I added or "Union" next to if C[i].className == "Part" PvPNinjaDragon 35 — 8y
Ad

Answer this question