I'm making a game that has a start menu in it. I want that GUI to disappear upon the player clicking the "Start Game" button, but it currently doesn't do anything when you click the button.
Here's my code:
local button = script.Parent
local toggled = false
local guiObj = ScreenGui
local function onButtonActivated()
if toggled == false then
guiObj:Destroy()
else
button.Text = "Start Game"
toggled = false
end
end
button.Activated:Connect(onButtonActivated)
Any tips would be appreciated, thanks! :)

4 comments
Use .MouseButton1Click instead of Activated
So would it be button.MouseButton1Click:Connect(onButtonActivated) instead? Because I tried that and it didn't work.
You set guiObj equal to ScreenGui when ScreenGui is not declared.
The original code said "guiObj = nill" but they told me I should make a reference to the ScreenGui because that's where the button is declared.