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

Play Button Not Working? (Error and Code HALP!)

Error: Players.Maythews.PlayerGui.Menu.MenuBackground.Play.Script:17: ')' expected (to close '(' at line 7) near ''

This is a Football Management GUI game I am making; here's the script.

Script:

-- all variables
local TN = game.Workspace.StarterGui.Customization.TeamName
local BG = script.Parent.Parent
local PB = game.Workspace.StarterGui.Menu.MenuBackground.Play
local TL = game.Workspace.StarterGui.Menu.MenuBackground.Tip
--close menu
PB.MouseButton1Click:connect(function()
	BG.Visible = false
	PB.Visible = false
	TL.Visible = false
	TN.Visible = true

	
	
end

This is for the starting menu but local TN is for after you press play, if that helps at all.

2 comments

0

Add a ')' after the 'end'.

0

Oh wow thanks, however the script still does not appear to work. Nothing happens when i press play.

2 answers

✓ Accepted answer

Whoops, I didn't look through it carefully enough. Not only did you forget the ) after the end, but you made the same mistake everybody else did when starting out: you attempted to change the properties of the StarterGui. Instead, you want to change the properties of the Player's PlayerGui so that they can see the changes themselves.

It can be tough to explain, so I fixed it for you below. I recommend reading through it to understand the changes.

wait() -- Waits to help make sure that objects load
--// Player Variables
Players = game:GetService("Players") -- Getting a reference to the PlayerService
LocalPlayer = Players.LocalPlayer -- Getting our player
PlayerGui = LocalPlayer.PlayerGui -- Getting our player's PlayerGui

--// Object Variables
BG = script.Parent.Parent
TN = PlayerGui.Customization.TeamName
PB = PlayerGui.Menu.MenuBackground.Play
TL = PlayerGui.Menu.MenuBackground.Tip

--// Closing Menu
PB.MouseButton1Click:connect(function()
	BG.Visible = false
	TN.Visible = true
	PB.Visible = false
	TL.Visible = false
end)

2 comments

0

Thank you so much! I am a beginner as you assumed, i'll be sure to keep this handy for future reference as well.

0

We all made this mistake starting out... anybody who says otherwise is a liar ;)

If you create a function this way, then you have to add a ")" after "end" to end the :connect() function.

Here's the script:

-- all variables
local TN = game.Workspace.StarterGui.Customization.TeamName
local BG = script.Parent.Parent
local PB = game.Workspace.StarterGui.Menu.MenuBackground.Play
local TL = game.Workspace.StarterGui.Menu.MenuBackground.Tip
--close menu
PB.MouseButton1Click:connect(function()
    BG.Visible = false
    PB.Visible = false
    TL.Visible = false
    TN.Visible = true
end) -- HERE! You forgot to add a ")" after "end"

If you have any problems, please leave a comment below. Thank you, and I hope this will help.

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