Help with Tweening Images left and right in frame

Im trying to setup a system to move images left and right and i cannot find out why this script isnt working correctly. Ive tried printing troubleshooting all positions print correctly and the output shows that its putting the correct images with the correct positions but they just go to the next position in the table. Ive tried to check if the button is executing the code twice but it doesnt im just not sure if my approach is completely wrong, but the left button works perfectly and doesnt act like this even though its the same code basically

	local function TweenClothesR(ClothingFrame)
		local Rack = ClothingFrame.Parent
		local str = tostring(tonumber(ClothingFrame.Name) + 1)
		local str_start = "Pos"
		local search = str_start .. str
		if tonumber(str) < 0 then
			search = "Pos0"
		elseif tonumber(str) > 4 then
			search = "Pos4"
		end
		local t = tostring(ClothingFrame)
		local ClothFrame = tonumber(t)
		if ClothFrame > 0 then
			local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
			local x = PositionsTable[search].x
			local y = PositionsTable[search].y
			local goal = {Position = UDim2.new(x, 0, y, 0)}
			TweenService:Create(Rack[ClothFrame], TweenInfo, goal):Play()
			ClothingFrame.Name = tonumber(ClothingFrame.Name) + 1
		else
			local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
			local x = PositionsTable["Pos0"].x
			local y = PositionsTable["Pos0"].y
			local goal = {Position = UDim2.new(x, 0, y, 0)}
			TweenService:Create(Rack[ClothFrame], TweenInfo, goal):Play()
			ClothingFrame.Name = tonumber(ClothingFrame.Name) + 1
		end
	end

Hi! Quick question: are you tweening each image individually? If so, is there a particular reason opposed to tweening one main frame containing each image?

yes i cant think of how id achieve the like moving animation with it all just in one frame but im really unfamiliar with tweeningservice tbh so this is stumping me

Simple. You would just have all of the images placed appropriately in a single, main frame, and you would tween the frame left or right depending on which arrow they click. You could also use math.clamp to set a minimum and maximum X value for the frame’s position to prevent it from going off screen.

1 Like

alright i will give that a try later maybe i just overcomplicated this heavily

1 Like

Wroked perfectly after a bit of testing i appreciate it i definitely just overcomplicated it lmao

1 Like

Awesome! If you need anything else, let me know!

P.S. You can close this topic by marking my message as the solution (next to the like button). Doing so would be greatly appreciated. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.