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

Mouse1 Click to disable GUI?

Asked by 4 years ago
Edited 4 years ago

I have a "resume" TextButton in my game's menu. I'd like the menu to disable/disappear when the TextButton is clicked. (Left click/Mouse button 1). Any help is appreciated, thanks :).

function OnClicked()
    script.Parent.Parent.Active = false


script.Parent.MouseButton1Click:Connect(OnClicked)  
end

the script doesnt WAAARARKKKAKKKRKROAKSDADADAWDASDZCZXCZ >:(

help plz

0
use Enabled instead of active. That just makes it so it cant be interacted with. If its a screengui, that is. And you have your connect statement inside the function. RunKittenzRComin 170 — 4y
0
Connect statement inside the function? jetpush123 2 — 4y
0
:connect() inside the function. put it outside. RunKittenzRComin 170 — 4y

2 answers

Log in to vote
0
Answered by
2ndwann 131
4 years ago
Edited 4 years ago

Perhaps this may work. (Assuming the button is a child of a frame)

-- Put this script inside the "resume" button

function onClicked()
    script.Parent.Parent.Visible = false -- hides the game menu
end

script.Parent.MouseButton1Down:Connect(onClicked) -- When the user click on the button, it will hide the game menu.

I hope this helps.

0
didnt work ;-; jetpush123 2 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
local Screen = ScreenGui -- screengui the button is in
local press = Button -- The button, can be any imagebutton, textbutton, etc.

button.MouseButton1Click:Connect(function()
    if Screen.Enabled == true then
        Screen.Enabled = false
    else
        Screen.Enabled = true
    end
end)

Should toggle on button press. Works in local or normal. Comment if theres an error

0
Note that this toggles the ScreenGui specified, sorry i diden't make that clear. The screengui can be ANY screengui. RunKittenzRComin 170 — 4y
0
And I missread. If you dont want a toggle, remove the else statement. RunKittenzRComin 170 — 4y
0
ok jetpush123 2 — 4y
0
didnt work jetpush123 2 — 4y
View all comments (2 more)
0
Thats a lot of information, thank you. I can now fix the problem and keep helping you. RunKittenzRComin 170 — 4y
0
I don't know whats wrong myself, so how can I tell you? I'm new, and you gave me completely new code from the original, I don't know it. jetpush123 2 — 4y

Answer this question