I am making an FPS and am currently customizing the main menu and I have got a Script so far Ill add it at the End. Anyway I have the script Insert a Text button and make the Text change to loading... and I want to make It so that when it reads "Ready To Play" It will Delete itself from the specific PlayerGui Folder. Any Ideas? SCRIPT--
-- Create ScreenGui local screenGui = Instance.new("ScreenGui") screenGui.Parent = script.Parent -- Create TextButton local textButton = Instance.new("TextButton") textButton.Parent = screenGui textButton.Position = UDim2.new(0, 25, 0, 50) textButton.Size = UDim2.new(0, 150, 0, 50) textButton.BackgroundColor3 = BrickColor.Black().Color textButton.Text = "Click To Play!" --[[Bind function to button click]]-- textButton.MouseButton1Down:connect(function() textButton.Text = "Loading..." end) wait(3) textButton.Text = "Ready To Play!" if textButton.Text == "Ready To Play" then game.Players.user.PlayerGui.ScreenGui:Destroy() if game.Players.user.PlayerGui.ScreenGui:Destroy() == true then print("MainMenu Deleted") end end
Okay, so, assuming this is a LocalScript, and assuming that the LocalScript is inside of the StarterGui, all you need to do is find the LocalScript's parent, and access the ScreenGui from there. So, you can use this edited version of your code:
-- Create ScreenGui local player = script.Parent.Parent.Parent local screenGui = Instance.new("ScreenGui") screenGui.Parent = script.Parent -- Create TextButton local textButton = Instance.new("TextButton") textButton.Parent = screenGui textButton.Position = UDim2.new(0, 25, 0, 50) textButton.Size = UDim2.new(0, 150, 0, 50) textButton.BackgroundColor3 = BrickColor.Black().Color textButton.Text = "Click To Play!" --[[Bind function to button click]]-- textButton.MouseButton1Click:connect(function() --changed to click, otherwise they could click & hold --ADDED THIS ALL INTO THE MOUSECLICK FUNCTION textButton.Text = "Loading..." wait(3) textButton.Text = "Ready To Play!" script.Parent.ScreenGui:Destroy() print("Menu Deleted") end)