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