How do you make a UI Background Moving Effect?

d397ae936bede57c3a622ed070a2d6bb
Someone has already asked this question and has gotten the answer but, I still don’t understand on how you would do it, all I know is that it has to do something with tweening and stuff.

Can someone please explain how you would do this?

21 Likes

I haven’t done this personally but you would utilise the Tween server as you’ve mentioned, and the ‘clip descendents’ property of Gui Objects.

You would have a background frame with a semi-transparent background with ClipDescendents enabled.

Then the effect within the background frame.

With a loop and the tween service you would animate this effect gui repeatedly by setting its position to the bottom right of the background frame, and move it to the top left of the frame;

local screenGui = script.Parent
local bgFr = gui:WaitForChild("BackgroundFrame")
local fxFr = gui:WaitForChild("EffectFrame")
local TS = game:GetService("TweenService")

function Tween(obj,prop,info) -- object to animate, properties to change, tween info.
  	info = info or TweenInfo.new(
		1,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		-1,
		true,
		0
	)
	TS:Create(obj,info,prop):Play()
end

while true do
	fxFr.Position = UDim2.new(0.75,0,0.75,0) -- set position to bottom right
	Tween( fxFr,  { Position = UDim2.new(0.25, 0, 0.25, 0) } ) -- Tween to top left
	wait(1)
end

33 Likes

Typo:

TS:Create(obj, info, prop):Play()

Also, why an indefinitely looping tween in an infinite while-loop?

5 Likes

Fixed it:
It works for moving it but, how do you make it look seamless?

local bgFr = script.Parent.BackgroundFrame
local fxFr = script.Parent.BackgroundFrame.EffectsFrame
local TS = game:GetService("TweenService")

function Tween(obj,prop,info) -- object to animate, properties to change, tween info.
  	info = info or TweenInfo.new(
		1,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		-1,
		true,
		0
	)
	TS:Create(obj, info, prop):Play()
end

while true do
	fxFr.Position = UDim2.new(0.75,0,0.75,0) -- set position to bottom right
	Tween( fxFr,  { Position = UDim2.new(0.25, 0, 0.25, 0) } ) -- Tween to top left
	wait(1)
end
7 Likes

Can you show what it looks like now?

Just tween an ImageLabel through a ScrollingFrame.

Thanks everybody, finally got it working correctly :3

8 Likes

What is this supposed to accomplish? OP is looking for an image to be tweened to create a sort of “moving underlay” for a frame. ScrollingFrame wouldn’t be useful in this situation, unless I’m missing something? A rationale for your response would be appreciated to understand the stance you’re coming from.

can you show me how you fixed it

Haha, this post was created back when I had no real clue about scripting, anyways, just think of the moving image as 4 quadrants. (4 zones)

You’re moving from the top left zone (starting) to the bottom right zone (ending), then once it reaches the ending zone, you immediately cut back to the starting zone. Assuming you’ve properly made the background seamless, it should appear as nothing changed. After that, you just play the same movement from top left to bottom right.

When I meant back then 4 years ago in terms of “fixed it”. What I actually meant was I just fixed a wrong labeling on the variable:

From:

local fxFr = gui:WaitForChild("EffectFrame")

to

local fxFr = script.Parent.BackgroundFrame.EffectsFrame

gui and script.Parent are the same thing but notice the EffectsFrame and EffectFrame

They were just spelled different causing it not to work at all in the beginning. Back then I had no idea so I just messed around.

If you want to use the same code, make sure to fit the variables and instances to the same names exactly AND check the output error window to find any errors that may pop up. If you have any other questions, send me a message instead of asking here :sweat_smile: Don’t want to continue bumping a 4 year old post.

3 Likes