Sliding gui help

I’m a pretty new scripter and I was wondering; how to make a frame that would slide across the screen? I know how to make a fading one with tween service so I’ve been wondering if it’s possible to make a sliding one and how to do it.

Ok so after playing around a bit, I realized you have to use UDim2 giving me the following code. Don’t look at the extra variables that don’t get used, those were used for a code that was there before

local plr = game.Players.LocalPlayer
local plrgui = plr:WaitForChild("PlayerGui")
local character = plr.Character
local rs = game:GetService("ReplicatedStorage")
local gui = script.Fading:Clone()
local atable = rs.TableGui
local ts = game:GetService("TweenService")
local died = rs.DiedGUI

gui.Parent = plrgui
atable.OnClientEvent:Connect(function()
	print("Fired client")
	local Frame = gui:WaitForChild("Frame")
        Frame:TweenPosition(UDim2.new(0,0,0,0),1)
end)

The important thing is to set the frame to a position you want it to slide from in the beginning!

Example:
If I want the frame to slide from the left into the middle, I need to set the Frame’s position to -1,0.
Why?
Because if I set the X axis to -1, that will mean the frame is outside the screen on the left, and 0 just means the Y axis is the same because I didn’t want it to curve from up or bottom.

If we want the Frame to return back, in my case, it would look like this:

Frame:TweenPosition(UDim2.new(0,0,0,0),1)
wait(2)
Frame:TweenPosition(UDim2.new(-1,0,0,0),1)

We have to wait 1 or more than 1 second so the First tween plays completely before we start the new one.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.