Answered by
7 years ago Edited 7 years ago
Just get the player mouse then put your morph function inside Button1Down function, like this :
01 | local plr = game.Players.LocalPlayer |
02 | local mouse = plr:GetMouse() |
05 | if plr.Character:FindFirstChild( "RightArm1" ) = = nil then |
06 | local g = script.Parent.Parent.RightArm 1 :Clone() |
07 | g.Parent = plr.Character |
08 | local C = g:GetChildren() |
10 | if C [ i ] .className = = "Part" or C [ i ] .className = = "UnionOperation" or C [ i ] .className = = "WedgePart" or C [ i ] .className = = "MeshPart" then |
11 | local W = Instance.new( "Weld" ) |
14 | local CJ = CFrame.new(g.Middle.Position) |
15 | local C 0 = g.Middle.CFrame:inverse()*CJ |
16 | local C 1 = C [ i ] .CFrame:inverse()*CJ |
21 | local Y = Instance.new( "Weld" ) |
22 | Y.Part 0 = plr.Character [ "RightUpperArm" ] |
24 | Y.C 0 = CFrame.new( 0 , 0 , 0 ) |
28 | local h = g:GetChildren() |
30 | if h [ i ] .className = = "Part" or C [ i ] .className = = "UnionOperation" or C [ i ] .className = = "WedgePart" or C [ i ] .className = = "MeshPart" then |
32 | h [ i ] .CanCollide = false |
38 | mouse.Button 1 Down:connect(onClick) |
EDIT :
Before, you could detect if the part belong to a player, and if he had a right arm. Now, as we define the player at the beginning, you can just detect if the player has a right arm (we already know that he is a player so , it would be useless to check if he has a Humanoid)
Anyways, i just replaced each "hit" by "plr.Character" in your script