I asked once before, and changed what was wrong, but the script still refuses to work. The problem I am having is closing the gui when a textbutton is clicked. Thanks in advance!
The script:
local titlescreen = Instance.new("ScreenGui") titlescreen.Parent = script.Parent -- Frame local titleframe = Instance.new("Frame") titleframe.Parent = titlescreen titleframe.Position = UDim2.new(0, 75, 0, 75) titleframe.Size = UDim2.new(0, 850, 0, 400) titleframe.Style = "RobloxRound" -- Text local titletext = Instance.new("TextLabel") titletext.Parent = titlescreen titletext.Position = UDim2.new(0, 400, 0, 85) titletext.Size = UDim2.new(0, 250, 0, 50) titletext.FontSize = "Size24" titletext.BackgroundTransparency = 1 titletext.Text = "Project Undefined" -- Button local titlebutton = Instance.new("TextButton") titlebutton.Parent = titlescreen titlebutton.Position = UDim2.new(0, 400, 0, 175) titlebutton.Size = UDim2.new(0, 250, 0, 50) titlebutton.FontSize = "Size14" titlebutton.Text = "Start" function onClicked() titlescreen.remove() end titlebutton.MouseButton1Down:connect(onClicked)
remove
is a method. It requires an argument, and calling it as a method automatically passes the object it was called from as the first argument: titlescreen:remove()
.
It is also deprecated, so write titlescreen.Parent=nil
or titlescreen:Destroy()
instead.