Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't this Gui, Frame slide when I set a undim2 script?

--Variables
local udim2 = UDim2.new
local Left,Center,Right = udim2(-1,0,0,0),udim2(0,0,0,0),udim2(1,0,0,0)
local easein,easeout,easesine = Enum.EasingDirection.In,Enum.EasingDirection.Out,Enum.EasingStyle.Sine
local SONGS = game.StarterGui.SONGS.Frame

--Loop
while true do
SONGS.Position = Left
SONGS:TweenPosition(Center,easeout,easesine,2,true)
wait(3.5)
SONGS:TweenPosition(Right,easein,easesine,2,true)
wait(2)
end

1 answer

Two things are not ideal with your script here.

local SONGS = game.StarterGui.SONGS.Frame

This accesses the StarterGui. This is NOT the same as the PlayerGui which is a different object. The PlayerGui is built from the local gui.

If this is a local script, we can make our new line be.

local player = game.Players.LocalPlayer
local SONGS = player.SONGS.Frame

See this article for more information on LocalPlayer.

The second change I suggest making is that the left side of the screen is actually UDim2.new(0,0,0,0) because 0,0 is the top left part of the screen. The horizontal center is actually UDim2.new(0.5,0,0,0).

Our new script is.

--Variables
local udim2 = UDim2.new
local Left,Center,Right = udim2(0,0,0,0),udim2(0.5,0,0,0),udim2(1,0,0,0)
local easein,easeout,easesine = Enum.EasingDirection.In,Enum.EasingDirection.Out,Enum.EasingStyle.Sine
local player = game.Players.LocalPlayer
local SONGS = player.PlayerGui.SONGS.Frame

--Loop
while true do
SONGS.Position = Left
SONGS:TweenPosition(Center,easeout,easesine,2,true)
wait(3.5)
SONGS:TweenPosition(Right,easein,easesine,2,true)
wait(2)
end

1 comment

0

Feel free to leave left, center, and right variables as the udim values you set. I was worried that you might think the script doesn't work if you could not see much of it happening on the screen.

This discussion is preserved as it was. New answers, comments, and votes are closed.