Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

1 comment

0

Button2Down is the right click

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.