I'm trying to get the player's screen size

Hello there! I’m trying to make the game print the screen size on the console.

I’ve tried workspace.CurrentCamera.ViewportSize but everytime it shows 1,1 on the console.

Am I doing something wrong? Thanks.

P.S: If you could send some tutorials on how to detect the player’s screen size, I’d be really happy.

1 Like
local mouse = player:GetMouse()
x = mouse.ViewSizeX
y = mouse.ViewSizeY
5 Likes

Thanks! But where should I put that script? Should it be a Script or LocalScript?

1 Like

it needs to be a local script

local player = game.Players.LcoalPlayer

local mouse = player:GetMouse()
x = mouse.ViewSizeX
y = mouse.ViewSizeY
9 Likes

Where should I put it? In the workspace? Or any ScreenGUI?

1 Like

oh, you can put it in StarterPlayer.PlayerScripts, or you can put it inside of your gui.

2 Likes

Thank you! I’ll try it.

Oh my god! Oh my god! It works. Thank you sooo much!

Anygrybirdcharacter, you can still respond.

Ah, no worries! I already did. Thanks!

And a little PSA: Make sure that you add 73 to the value of the Y to get the actual size.

3 Likes

that is only if you have GuiInset enabled. 73 is the amount of pixels on your specific screen that the UI inset takes up but on everyone’s screen it is different.

3 Likes