Tweening a UI frame on one axis

Hello, so I want to tween my frames using one axis (X)

But it does this instead:

robloxapp-20230106-2212434.wmv (114.7 KB)

local function tween(obstacle)
    local move = TweenService:Create(obstacle, TweenInfo.new(2), { Position = UDim2.new(-0.5, 0, obstacle.Position.Y) })
    move:Play()

    move.Completed:Connect(function()
        obstacle:Destroy()
    end)
end
1 Like

–obstacle is a frame
–tween(obstacle)

Yes it is a frame the obstacle is a frame

I think you may have forgot the 4th number inside UDim2

Does a thing like this work?

UDim2.new(-0.5, 0, obstacle.Position.Y, 0)

Also, is obstacle.Position.Y absolute size (using pixels) or relative (from 0 to 1)?
If it’s relative the above might work, but if absolute you should replace the positions of the numbers:

UDim2.new(-0.5, 0, 0, obstacle.Position.Y)

Idk if its relative or not I’m confused and doing UDim2.new(-0.5, 0, obstacle.Position.Y, 0) didn’t work

Ow, would you mind printing obstacle.Position.Y?

it prints

So that’s in absolute. Also, the Y position seems really near to 0. So it might be one thing. Looking at your video I saw the the upper squares moved correctly, their anchor position by default might be (0,0) in relative size.

But the below ones are moving diagonally, So you might want to check your anchored position or have something similar to (0, 1) the 1 being the Y position?

I just want it to move on one axis and Idk what to do I tried setting all the anchore point to 0,1 and it still didn’t work

Sorry if I didn’t figure out. I need to leave now, but I would like to try to get a view again in another moment.

I solved it while I was just messing around with it

I just did this

UDim2.new(-0.5, obstacle.Position.X.Offset, obstacle.Position.Y.Scale, 0)
1 Like

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