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

How to detect if mouse is held down and make a gui visible if it is?

Asked by 3 years ago

I'm trying to make a gui visible when I hold down left mouse button and make it disappear when I let go of the left mouse.

This is the code I wrote but I don't know why it isn't working

local circle = script.Parent.Circle

local UIS = game:GetService("UserInputService")
local MouseDown = false

UIS.InputBegan:Connect(function(a)
    if a.UserInputType == Enum.UserInputType.MouseButton1 then
        circle.Visible = true
    end
end)
UIS.InputEnded:Connect(function(a)
    if a.UserInputType == Enum.UserInputType.MouseButton1 then
        circle.Visible = false
    end
end)

Answer this question