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

Mouse1 Click to disable GUI?

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

3 comments

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.

0

Connect statement inside the function?

0

:connect() inside the function. put it outside.

2 answers

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.

1 comment

0

didnt work ;-;

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

6 comments

0

Note that this toggles the ScreenGui specified, sorry i diden't make that clear. The screengui can be ANY screengui.

0

And I missread. If you dont want a toggle, remove the else statement.

0

ok

0

didnt work

0

Thats a lot of information, thank you. I can now fix the problem and keep helping you.

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.

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