I want to make a Title Screen with ScreenGuis, but the "Play" button isn't working. This is the code that I have been trying to tinker with:
01 | wait( 0.25 ) |
02 | local Screen = script:WaitForChild( 'TitleScreenGui' ) -- ScreenGui |
03 | local screen = Screen:Clone() -- ScreenGui that will be put into the PlayerGui |
04 |
05 | game.Players.playerAdded:connect( function (player) |
06 | local startergui = player:WaitForChild( 'PlayerGui' ) -- PlayerGui |
07 | screen.Parent = startergui -- ScreenGui put into PlayerGui |
08 | screen.Enabled = true |
09 | end ) |
10 |
11 | screen.Child.Child.Child.MouseButton 1 Click():connect( function (player) |
12 | -- screen.Child.Child.Child is the "Play" button |
13 | screen.Enabled = false |
14 | end ) |
I searched and read about TextButton
and MouseButton1Click
many times but I still can't figure it out.
There's a syntax error on line 11, MouseButton1Click
is not a method, it is an event.
An easy fix is just to replace line 11 with:
screen.Child.Child.Child.MouseButton1Click:connect(function(player)
Also, click only fires if the user presses mouse one and lets go of it while the cursor is in the bounds of the TextButton
object. If you just want it to fire upon the initial click (which I recommend), use MouseButton1Down:connect()
.