Scaling GUI Tweens

So I don’t know how but for some reason one of my GUIs isn’t tweeting to scale. The tween works perfectly and goes to the right position on the default view but when I change it to iPhone view it goes to a completely different position. None of my other GUIs have done this.
Code:

local SuccessMessageIn = Tween:Create(Success,TweenInfo.new(0.75,Enum.EasingStyle.Exponential,Enum.EasingDirection.Out),{Position = UDim2.new(0, 473,0, 0)})
1 Like

You are using “pixels”(not sure what it’s called) to tween. This means that its size is varied from screen to screen. In order to achieve the same position on everywhere, you need to use the scale properties, which scales the frame to a portion of the screen. So for example, UDim2.new(0.3,0,0.2,0) will create a frame which will have a ratio of 3:10 in the x axis and a ratio of 2:10 y axis. (Scale is the first property of each axis in UDim2)

image

in this part, you should manipulate the scale property of UDim2 too, so this can be replaced as:

{Position = UDim2.new(0.45, 0,0, 0)}

note that this is just an example of how you can change it, the value is adjustable.

I’m still a little confused. I want to have the GUI come down from the top into the middle. How would I get the position for the middle? If possible, could you give me the position?

What do u mean? I didn’t withdraw this post lol

The middle Position of the screen in Scale is UDim2.new(0.469, 0, 0.426, 0) if that is what you asked.

The middle for me is: UDim2.new(0.387, 0,0.458, 0)

Did you scale your UI in size?

Yes, I used a plugin to scale my GUI. It works with every other GUI I’ve done, I don’t think that’s the problem.

1 Like

If you want it in the middle, set the anchor point of the Ui element to 0.5,0.5. Then tween the position to 0.5,0,0.5,0 instead and you should be good to go!

2 Likes

Alright well, I put the middle position on my computer into the tween and it works perfectly. When I switch my view to mobile to check the scaling & positioning it’s completely messed up. It’s only the X axis that doesn’t seem to work.

the middle of a frame is determined from a calculation. If your frame is UDim2.new(0.3,0,0.2,0) then the middle is UDim2.new((1-0.3)/2,0,(1-0.2)/2,0)

1 Like

As @IFthenElse246 said, change the Anchor point to 0.5, 0.5 and set the Tween Position
to 0.5, 0 ,0.5, 0.

I don’t want the GUI exactly in the middle. I only need the X axis to be in the middle because the Y axis works fine.

1 Like

So change the X axis to 0.5 in Scale.

to do that, do anchor point = 0.5,0 and position = (what ever you want),(whatever you want),0.5,0

This is what I’m trying to do and it works in that scale but not when I put it to iPhone.

What position did you set it to tween to?

You can see the line of code I used in the original post.

The position you set is not in Scale but on Offset, it might be the problem.
Convert the Offset value to Scale.

I’ve used this line for every other GUI tween and it’s worked fine… Why not this 1 GUI?