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:
wait(0.25) local Screen = script:WaitForChild('TitleScreenGui') -- ScreenGui local screen = Screen:Clone() -- ScreenGui that will be put into the PlayerGui game.Players.playerAdded:connect(function(player) local startergui = player:WaitForChild('PlayerGui') -- PlayerGui screen.Parent = startergui -- ScreenGui put into PlayerGui screen.Enabled = true end) screen.Child.Child.Child.MouseButton1Click():connect(function(player) -- screen.Child.Child.Child is the "Play" button screen.Enabled = false 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()
.