MouseButton2Down not working?

I have made attempted to make a system where when a player right clicks something, it prints out a string.
If I do this following code, it doesn’t activate when right clicked, however if I replace the “MouseButton2Down” with “MouseButton1Down”, it will work when left clicking.

CODE

local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
Mouse.Button2Down:Connect(function()
print(“Has Right Clicked”)
end)

How do I make it work with right clicking?

You should really use “UserInputService” rather than Mouse for stuff like input and controls.

1 Like

This code here works perfectly fine with me, Make sure your code is in a local script inside the starter client.

Heres the code I used (Exactly the same except for an added print, wanted to see if the character loaded in too fast)

local plr = game.Players.LocalPlayer

print(plr)

local Mouse = plr:GetMouse()

Mouse.Button2Down:Connect(function()

print("Has Right Clicked")

end)

It may work fine however, for the future he should instead use UserInputService seeing as it’s more efficient, and has many more viable customizations.