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

how would i be able to make an x button for a gui?

Asked by 7 years ago

i know that you use

textButton.MouseButton1Down:connect(function()

to actually make the text button do the script, build what do i put inbetween?

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

You could do this put it in a local script inside a textbutton.

local player = game.Players.LocalPlayer
local closebutton = script.Parent
local Frame = script.Parent.Parent

closebutton.MouseButton1Click:connect(function()
        Frame.Visible = false
end)

Frame is where the frame or gui you want to close is,

You could also tween the Gui off of the screen, like this:

local player = game.Players.LocalPlayer
local closebutton = script.Parent
local Frame = script.Parent.Parent

closebutton.MouseButton1Click:connect(function()
        Frame:TweenPosition(UDim2.new(-30, 0, 0, 0),1,5,2.8)
end)

Look into TweenSize and TweenPosition here:

http://wiki.roblox.com/index.php?title=API:Class/GuiObject/TweenSize http://wiki.roblox.com/index.php?title=API:Class/GuiObject/TweenPosition

Ad
Log in to vote
1
Answered by 7 years ago

instead of all that you could have easily put this, if you want to hide the chat

script.Parent.MouseButton1Click:connect(function()
    script.Parent.Parent.Visible = false
end

if that doesn't work change the Parent to one parent and instead of the visible, change it to enabled

i just wanted to dump this post here.

Answer this question