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

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

Asked by 6 years ago
--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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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
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. User#18718 0 — 6y
Ad

Answer this question