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

How to create a TextButton to close out existing ScreenGui?

I am very very very new to scripting i barely know the language but i know a few things but i need help with creating a TextButton that will close out my existing screenGui. :) Also, any mentoring on scripting would be delighting.

-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent
 
-- Create Frame
local frame = Instance.new("Frame")
frame.Parent = screenGui
frame.Position = UDim2.new(0, 350, 0, 75)
frame.Size = UDim2.new(0, 400, 0, 250)
frame.BackgroundColor3 = BrickColor.Blue().Color
frame.BackgroundTransparency = .3

-- Create TextLabel
local textLabel = Instance.new("TextLabel")
textLabel.Parent = screenGui
textLabel.Position = UDim2.new (0, 350, 0, 75)
textLabel.Size = UDim2.new (0, 400, 0, 250)
textLabel.Text = "Welcome, click below to play! (Unfinished product, report bugs to me)"
textLabel.BackgroundTransparency = 1

-- Create TextButton to close out the existing screen Gui...Help

^ pretty much creating a play button to close out the gui.

1 answer

local textbutton = Instance.new("TextButton")
textbutton.Parent = screengui -- Idk what you want these to be.
textbutton.Position = UDim2.new (0, 0,0,0)
textbutton.Size = UDim2.new  (0,0,0,0)
textbutton.Text = "Play"
textbutton.BackgroundTransparency = 1
 
function onClick(mouse)
	script.Parent.ScreenGui:remove()
end
script.Parent.ScreenGui.textbutton.MouseButton1Down:connect(onClick)

Hope this helps

2 comments

0

remove(). Are you a troll?

0

Yes :3

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