Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Get Screen Size in Pixels?

Asked by 5 years ago

Title says it all

I'm trying to get the screen size (specifically, its width) in pixels for a calculation. ViewportSize gave me the answer for a short time (I think) but now just prints 1,1 which makes sense but does not suit my needs

0
The screen size in pixels is different for everyone, so the screensize in pixels on your monitor will be different on someone else's monitor/mobile device/console. It's usually best to use the relative screen height and width (the 1,1) so whatever you're making looks the same on everyone' device. ShinyGriffin 129 — 5y
0
The camera's ViewportSize property is exactly what you need. It does give the size in pixels. If its value is (1, 1) then something is wrong. ozzyDrive 670 — 5y

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago

If ViewportSize doesn't seem to be working for you, you can try use the ViewSizeX and ViewSizeY properties of the player's mouse. For example, to print the width of the screen in pixels, you could do something like:

local Mouse = game.Players.LocalPlayer:GetMouse()
print(Mouse.ViewSizeX)

in a LocalScript.

Ad

Answer this question