Question, How Would I make Gui move off-screen?

I have a pretty good idea of how to do this, but I can’t seem to figure it out. here is my idea:

local Button1 = script.Parent
local function onButtonActivated()
	-Move The Gui right
    -Wait Three Seconds
    Script.Parent.Enabled = false
end
Button1.Activated:Connect(onButtonActivated)

I just don’t know what the Move the Gui Right or Wait Three Seconds is.

You can use a tween on the Position, or you could just use the TweenPosition built into buttons.

Where the position at a corner of the screen would be

Sorry for the edits, I understand now you need help with the properties.

The position of the frame/gui is a Udim2, with X and Y.

{(1,0),(2,0)}

1 is the position of X, 0 being its offset.
2 is the position of Y, 0 being its offset.

Guiframe.Position = Udim2.new(1,0,2,0)

This would set the position to the edge of the screen and raise it out of bounds because of Y being larger than 1, which is the edge.

{1,0}
{1,0}


{A,B} 

-- A is position, B is offset


-- Position is based on total screen size, as a ratio. 
--`Offset is how many pixels you're translating, but
-- you can choose to use either one as you see fit

If you go larger than 1 or lower than 0, it will offset out of bounds. You can also use the API to get the user screen size in pixels, and position it based off that!

You can just tweenservice for that
Here is an example
This should work with EVERY device.

script.Parent:TweenPosition(UDim2.new(0,0,0,0),"InOut","Sine",1) -- the 1 is the time.
task.wait(1)
script.Parent.Enabled = false
local Button1 = script.Parent
local function onButtonActivated()
	game:GetService("TweenService"):Create(Button1, TweenInfo.new(3,Enum.EasingStyle.Quart, Enum.EasingDirection.InOut,0,false,0),{Position = UDim2.new(Button1.Position.X.Scale + 5, Button1.Position.Y.Scale)}):Play()
	task.wait(3)
	script.Parent.Enabled = false
end
button.Activated:Connect(onButtonActivated)
2 Likes

He could easy just use TweenPosition property.

Thank you @Citrozi :+1: :+1:

1 Like

Hey @Citrozi, can you please give me a version of:

local Button1 = script.Parent
local function onButtonActivated()
	game:GetService("TweenService"):Create(Button1, TweenInfo.new(3,Enum.EasingStyle.Quart, Enum.EasingDirection.InOut,0,false,0),{Position = UDim2.new(Button1.Position.X.Scale + 5, Button1.Position.Y.Scale)}):Play()
	task.wait(3)
	script.Parent.Enabled = false
end
button.Activated:Connect(onButtonActivated)

But with the GUI going from the middle to Down?

sure

local Button1 = script.Parent
local function onButtonActivated()
	game:GetService("TweenService"):Create(Button1, TweenInfo.new(3,Enum.EasingStyle.Quart, Enum.EasingDirection.InOut,0,false,0),{Position = UDim2.new(Button1.Position.X.Scale, Button1.Position.Y.Scale - 5)}):Play()
	task.wait(3)
	script.Parent.Enabled = false
end
button.Activated:Connect(onButtonActivated)
1 Like

Thanks, @Citrozi Great job. :+1:

1 Like
game:GetService("TweenService")

Should move this outside the function.