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

Get Screen Size in Pixels?

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

2 comments

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.

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.

1 answer

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.

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