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

Make UIS not work when I interact with GUI?

Asked by
SirNoobly 165
10 years ago

How do I make User Input Service not work when I click on a button in the GUI? Because if I click the GUI button it will still take in Enum.UserInputType.MouseButton1.

1 answer

Log in to vote
2
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

There is no way to disable User Input entirely, as then you would not be able to do anything to the client. You can, however, make a variable that if you click a button your code is no longer ran.

01local disabled = false
02local button = script.Parent
03 
04button.MouseButton1Click:connect(function()
05    if disabled then
06        disabled = false
07    elseif not disabled then
08        disabled = true
09    end
10end)
11 
12game:GetService("UserInputService").InputBegan:connect(function()
13    if not disabled then
14        --code
15    end
16end)
0
Another method is to check if the Mouse is within the bounds of a GUI object when it is clicked. It's a little bit more dificult to implement, but then all the logic is in one place. adark 5487 — 10y
Ad

Answer this question