Udim2 not setting correct? How can I fix it?

hello. so I am trying to make a swiping feature for a roblox phone game im currently working on. i think all my math is right but when i go to actually setting the position is does something weird and I don’t really know how to fix it. hoping you guys will be able to help!

              RunService.RenderStepped:Connect(function()
					if Holding then
						--# Math
						local YDifference = (startY - Mouse.Y)
						
						local realY = (1 / (PhoneWallpaper.AbsoluteSize.Y / Mouse.ViewSizeY)) * (Mouse.Y - PhoneWallpaper.AbsolutePosition.Y) / Mouse.ViewSizeY
						
						realY = tonumber(string.sub(realY, 1, 4))
						
						print(realY)
						
						--# Following
						PhoneElements.Swipe.Position = UDim2.new(0, 0.33, 0, realY)
						
						--# Full Swipe
						if YDifference >= 400 then
							print('FULLY SWIPED')
							
							--# Disconnect
							Functions.unlockSwipe:Disconnect()
							Functions.unlockSwipeEnd:Disconnect()
							Functions.swipeRunRendered:Disconnect()
						end
						wait(0.1)
					end

whenever it gets activated it just does this:

Maybe modifying this line

PhoneElements.Swipe.Position = UDim2.new(0, 0.33, 0, realY)

to this line:

PhoneElements.Swipe.Position = UDim2.new(0.33, 0, realY, 0) 

might resolve the issue you have

1 Like

Was my previous comment the solution to your problem?
If so, make sure to mark it as the solution!

You need to convert offset to scale.