RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"the gui doesnt close when i click play"
If you want the GUI to close when you click a play button, you'll need to write a script for that button which changes the GUI's visibility. Here's an example: ```lua -- assuming 'PlayButton' is the name of your button and 'MyGui' is the name of your GUI local Players = game:GetService("Players") local function onPlayerAdded(player) local playerGui = player:WaitForChild("PlayerGui") -- This is how you access PlayerGui local MyGui = playerGui:WaitForChild("MyGui") local PlayButton = MyGui:WaitForChild("PlayButton") local function onButtonClick() MyGui.Enabled = false -- This will hide the GUI end PlayButton.MouseButton1Click:Connect(onButtonClick) end Players.PlayerAdded:Connect(onPlayerAdded) ``` In this script, when a player is added, the function `onPlayerAdded` is called with the player as the argument. Inside this function, `WaitForChild("PlayerGui")` is used to get the PlayerGui of the player. Then, `WaitForChild("MyGui")` is used to get the GUI, and `WaitForChild("PlayButton")` is used to get the play button. A function `onButtonClick` is defined which sets the `Enabled` property of the GUI to `false`, effectively hiding it. This function is connected to the `MouseButton1Click` event of the play button, so it will be called when the button is clicked.