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

How do I make my point and click script compatible with right clicks?

Asked by
palpc 0
10 years ago

here is the code

if m.Hit == nil then return end
if m.Hit.p == nil then return end
if m.Target == nil then return end
if m.Target.Parent == nil then return end
local Hit = m.Hit.p
local Target = m.Target
if ((((Hit) - (game.Players.LocalPlayer.Character:findFirstChild("Torso").Position)).magnitude)<=50) then
game.Players.LocalPlayer.Character:findFirstChild("Humanoid"):MoveTo(Hit,Target)
end
end

I've been thinking about tweaking

local m = game.Players.LocalPlayer:GetMouse()
m.Button1Down:connect(function() onButton1Down(m) end)
function onButton1Down(m)

But, I just want to make sure it'd be the right thing to do... Any advice?

0
Button2Down is the right click Thetacah 712 — 10y

1 answer

Log in to vote
1
Answered by
bbissell 346 Moderation Voter
10 years ago

When you call the function with the event of "Button1Down"

m.Button1Down:connect(function() onButton1Down(m) end)

By changing

m.Button1Down

to

m.Button2Down

The event will be fired with right click.

Ad

Answer this question