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.

local uis = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

uis.InputBegan:Connect(function(Start,End)
    if mouse.Button2Down then
        print("mouse.Button2Down worked")
    elseif mouse.Button2Up then
        print("mouse.Button2Up worked")
    end
end)

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:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()


mouse.Button2Down:Connect(function() -- function fires when your right mouse button is clicked down
    print("mouse.Button2Down worked")
end)

mouse.Button2Up:Connect(function() -- function fires when your right mouse button is released
    print("mouse.Button2Up worked")
end)
Ad

Answer this question