Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to create a TextButton to close out existing ScreenGui?

Asked by
airkor 10
8 years ago

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

Log in to vote
0
Answered by 8 years ago
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

0
remove(). Are you a troll? unmiss 337 — 8y
0
Yes :3 pluginfactory 463 — 8y
Ad

Answer this question