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.

local disabled = false
local button = script.Parent 

button.MouseButton1Click:connect(function()
    if disabled then
        disabled = false
    elseif not disabled then
        disabled = true
    end
end)

game:GetService("UserInputService").InputBegan:connect(function()
    if not disabled then
        --code
    end
end) 
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