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

Why is my script meant to avoid mouse input detecting it?

Asked by 6 years ago

(In a local script)

game:GetService("UserInputService").InputBegan:connect(function(input)
if not input.UserInputType== Enum.UserInputType.MouseButton1 or Enum.UserInputType.MouseButton2 or Enum.UserInputType.MouseButton3 then
--Do my other code here
end

1 answer

Log in to vote
1
Answered by 6 years ago

You only compare the first Enum and not the others, you need to also compare the other Enums.

You might also want to make variables on the enums.

local m1, m2, m3 = Enum.UserInputType.MouseButton1, Enum.UserInputType.MouseButton2, Enum.UserInputType.MouseButton3

game:GetService("UserInputService").InputBegan:connect(function(inputObj)

    -- compare each mouse inout
    if inputObj.UserInputType == m1 or inputObj.UserInputType == m2 or inputObj.UserInputType == m3 then return end -- return out of the function if one is found

    -- code

end)

I hope this helps.

0
Works perfectly, thank you! Void_Frost 571 — 6y
Ad

Answer this question