Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you get the center of the screen with Vector2?

Title explains it, I've tried everything. I know i can do IngoreGuiInSet, but i can't just figure out how to do get the center.

4 comments

0

use scale, Vector2.new(0.5,0,0.5,0) is the center

0

Tried this before, didn't work. The center was so far up to the left and up.

0

Mmm... did you set the AnchorPoint to 0.5, 0.5?

0

if u didn't thats why that happens.

2 answers

If you're using ScreenGuis, use UDim2.

Assuming that a LocalScript is inside your GUI:

local centerScreen = UDim2.new(0, 0, 0, 0)
local gui = script.Parent

gui.Position = centerScreen

If you don't know what UDim2 is, here are the roles of the numbers in it:

UDim2.new(x scale, x offset, y scale, y offset)

I suggest editing the scales, because the offset's size doesn't change according to the device's size.

1 comment

0

Once again, not for a gui! I'm using it to shoot a raycast towards the center of the player's screen.

This discussion is preserved as it was. New answers, comments, and votes are closed.