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

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

(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

✓ Accepted answer

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.

1 comment

0

Works perfectly, thank you!

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