This is my script:
local bgFr = script.Parent:WaitForChild("BackgroundFrame")
local fxFr = bgFr:WaitForChild("EffectsFrame")
local TS = game:GetService("TweenService")
fxFr.AnchorPoint = Vector2.new(0.5, 0)
local tweenInfo = TweenInfo.new(
3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
-1,
false
)
fxFr.Position = UDim2.new(0.5, 0, 1.5, 0)
local tween = TS:Create(fxFr, tweenInfo, {
Position = UDim2.new(0.5, 0, -0.5, 0)
})
tween:Play()
My background frame is a frame, my effects frame is an image label. i have a tv and i am trying to make it look like a animated background. I am using a surface Gui, and i think that’s why its not working. can someone help?
Are you using local scripts or regular ones? If you are using local scripts, make sure to move your surface gui to startergui and set its adornee to the old parent.
I should be able to help you here, since I once made a SurfaceGUI-based working phone (although I’m a bit rusty with studio, so forgive me for any mistakes)
Essentially, when your game starts, your TweenService runs for 3 seconds, moving to (Call this position B - (scX 0.5, scY -0.5)). After the 3 seconds, it attempts to repeat moving to position B from… position B.
We can see the problem clearly here: your script is simply at its destination already, so it looks like it’s doing nothing!
Now, I assume you want it to repeat. You did the right thing with the ‘-1’ on repeat but, you have two options here to actually make it work.
A: “I want it to make it look like it keeps moving in one direction” - Simply turn it into a function or use a ‘for loop’. Personally, I like functions since it’s easier to explain. Just call your function again inside the function and it should loop. You can also turn off the ‘Repeats indefinitely’ and just set it to one-time since the loop will handle the repeated calling of the tween and loop the animation
B: “I want it to go from right to left then left to right” - Turn your ‘false’ for ‘reverses’ into ‘true’. This just means, when it goes from A to B, it will go back from B to A, in one :Play()
@mechclash ‘s suggestion wouldn’t really help you there, since I know that Tweening SurfaceGUIs does indeed work (read above), and the error is just in how you wrote your code.
TL;DR: Make it loop, setting the position again manually!
Hope this helps.
could you re-write the script? Because i don’t i know what you mean by its at the destination already. also, i copied everything and put it in a normal gui in startergui and it worked.
this actually worked. ty! but, it shows the gui moving, and then it shows the background, and then it does the image again. how can i make it sao that it keeps repeating and looks smooth?
nevermind. i fixed it with using 2 imagelabels! anyways, i will mark your answer as the solution as that worked.