Skip to main content

Automatically calculating the YOffset

Most of the time the screens are not curved or tilted vertically, so we added an automatic way of calculating the distance between the top of your canvas and the screens

You can add a part to your game and place it at the top of the top-most screen. In other words, the part should be at the height of the top of your imaginary 2D canvas.

The part doesn't need to be named anything specific, but we use the name TopMarker

tip

Roblox counts the positions of parts from the middle, so the middle of your part should be at the top of your screens.

Example

Continuing the example from the previous page, let's add a top marker part to our screens. Create a new part and place it on top of the highest screen, then move it so its center is touching the top of that screen. Name this part TopMarker. Make sure to also anchor it. In the future you should make it transparent and non-collidable, but that's not the point of this tutorial.