UI Frames aren't moving

Greetings, fellow robloxians. I have just stumbled upon an issue which seems to be minor but I can’t seem to comprehend why it is happening. I’m working on creating moving menus and I’m making it so that they’re all activated by a single script.

Here’s the script:

local TweenService = game:GetService("TweenService")
local TweenInfo1 = TweenInfo.new(1, Enum.EasingStyle.Linear)



for i,v in pairs(script.Parent:GetChildren()) do
	if v:IsA("SurfaceGui") then
		local Main_Frame = v:FindFirstChild("Frame")
		local State = v:FindFirstChild("State")
		local Leading_Page = v:FindFirstChild("Leading_Page").Value
		if State:IsA("IntValue") and Main_Frame:IsA("Frame") and Leading_Page:IsA("Frame") then
			while true do
				coroutine.wrap(function()
				if State.Value >= 5 then -- This means that when the menu has reached the last page, it goes back to the starting page
					State.Value = 0
					Leading_Page.Position = UDim2.new(6,0,0,0) -- Leading page is the first page of the menu
					TweenService:Create(Main_Frame,
						TweenInfo1,
						{Position = Main_Frame.Position + UDim2.new(-1,0,0,0)}
					):Play()
					wait(7)
					Main_Frame.Position = UDim2.new(0,0,0,0)
					Leading_Page.Position = UDim2.new(0,0,0,0)
				end
				TweenService:Create(
					Main_Frame,
					TweenInfo1,
					{Position = Main_Frame.Position + UDim2.new(-1,0,0,0)}
				):Play()
					State.Value = State.Value + 1
					
				end)
				wait(7)
				end
			end
		end
	end

For some reason, the menus aren’t moving and are staying in an idle position.

Parents:

Any suggestions on why this is occurring?

1 Like

Pretty sure you cannot use arithmetic symbols on a UDim2; you have to specify which axis you want to apply arithmetic operations to.

1 Like

From experience, arithmetic symbols do work with UDim2 operations.

Why did you put SurfaceGui in StarterGui?