Any Ideas on how to make a moving background GUI

Hi, Basically I want to have a start screen with a moving back ground GUI.

So I want to tween the GUI from right to left. but for some reason it goes to the top left, I think the udim I put in is incorrect but now sure, also I think cloning is needed so the background is seen at all time, again not to sure tho.

script:

local gui = script.Parent.Background

while true do
	gui:TweenPosition(UDim2.new(0,0.5,0))
	wait()
end

I don’t have much experience with guis, tweening, Cframes etc.

screenshot of my problem:

1 Like

Do you mean you want the UI to go from the middle of the screen to the left of the screen? From off the screen to the right to off the screen of the left? Could you maybe provide a visual?

Basically its a start screen that will keep on moving from right to left.

Gotcha.

So basically, you’d want to slowly tween it from left to right.

local gui = script.Parent.Background
gui.AnchorPoint = Vector2.new(0.5,0.5) -- just makes it easier
gui.Position = UDim2.new(1.5,0,0.5,0) -- UDim2's contain 4 values, not 3; Scale X, Offset X, Scale Y, Offset Y respectively.

local tweenService = game:GetService('TweenService')
tweenService:Create(gui, TweenInfo.new(10,Enum.EasingStyle.Linear), {Position = UDim2.new(-1.5,0,0.5,0)}):Play()

You should also probably take a look into TweenService docs if you haven’t already.

2 Likes

How would I make this keep on going? I think it involves cloning. Basically I don’t want the player to himself

You could probably do it with a loop that makes a new frame each time the tween ends. Since we’re using the EasingType linear it wouldn’t really look like it’s ever stopping.

Try this, it should give an illusion of an infinitely scrolling background:

local tweenService = game:GetService('TweenService')
local baseFrame = script.Parent.Background

local oldFrame = baseFrame
local newFrame = baseFrame:Clone()
newFrame.Parent = baseFrame.Parent
while true do
	newFrame.Position = UDim2.new(1,0,0,0)
	oldFrame.Position = UDim2.new(0,0,0,0)
	local tween1 = tweenService:Create(newFrame, TweenInfo.new(10, Enum.EasingStyle.Linear), {Position = UDim2.new(0,0,0,0)})
	local tween2 = tweenService:Create(oldFrame, TweenInfo.new(10, Enum.EasingStyle.Linear), {Position = UDim2.new(-1,0,0,0)})
	tween1:Play()
	tween2:Play()
	tween1.Completed:Wait()
	oldFrame:Destroy()
	oldFrame = newFrame
	newFrame = oldFrame:Clone()
	newFrame.Parent = oldFrame.Parent
	newFrame.Position = UDim2.new(1,0,0,0)
end
2 Likes

the gui for some reason is higher then it should be and also it’s not after teen it stops, for some reason its not a loop :frowning:

Switch the AnchorPoint back to 0,0 I also made an edit to the post, the new code should work.

THANKS A LOT :slight_smile: :slight_smile:

1 Like