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

Turn this into a click to morph script?

Asked by 7 years ago
Edited 7 years ago

How would I go about turning this from a touch to morph into a click to morph script?

01function onTouched(hit)
02if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("RightArm1") == nil then
03    local g = script.Parent.Parent.RightArm1:clone()
04    g.Parent = hit.Parent
05    local C = g:GetChildren()
06    for i=1, #C do
07        if C[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" or C[i].className == "MeshPart" 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 35 lines...

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Just get the player mouse then put your morph function inside Button1Down function, like this :

01local plr = game.Players.LocalPlayer
02local mouse = plr:GetMouse()
03 
04function onClick()
05if plr.Character:FindFirstChild("RightArm1") == nil then
06    local g = script.Parent.Parent.RightArm1:Clone()
07    g.Parent = plr.Character
08    local C = g:GetChildren()
09    for i=1, #C do
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")
12            W.Part0 = g.Middle
13            W.Part1 = C[i]
14            local CJ = CFrame.new(g.Middle.Position)
15            local C0 = g.Middle.CFrame:inverse()*CJ
View all 38 lines...

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

0
Thank you, I'm not sure how to modify the rest but I appreciate the help to get me started felonymartinez 12 — 7y
0
No problem. Before, you could detect if the part belong to a player, and if you can find his right arm. I edited my answer to help you more. I hope it will help you NotZuraax 68 — 7y
0
Thanks a ton! felonymartinez 12 — 7y
Ad

Answer this question