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

I can use Button2Down just fine, but not Button2Up. Help?

Asked by 4 years ago

First if statement works, not the second.

01local uis = game:GetService("UserInputService")
02 
03local player = game.Players.LocalPlayer
04local mouse = player:GetMouse()
05 
06uis.InputBegan:Connect(function(Start,End)
07    if mouse.Button2Down then
08        print("mouse.Button2Down worked")
09    elseif mouse.Button2Up then
10        print("mouse.Button2Up worked")
11    end
12end)

1 answer

Log in to vote
1
Answered by 4 years ago

This is because UserInputService is not the same as Mouse, the way I would do this is like this:

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse()
03 
04 
05mouse.Button2Down:Connect(function() -- function fires when your right mouse button is clicked down
06    print("mouse.Button2Down worked")
07end)
08 
09mouse.Button2Up:Connect(function() -- function fires when your right mouse button is released
10    print("mouse.Button2Up worked")
11end)
Ad

Answer this question