generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Does anyone know the width of the game screen?

Previous Thread :: Next Thread 
SlimeMan22 is online. SlimeMan22
Joined: 10 Mar 2012
Total Posts: 1210
07 Aug 2016 10:34 AM
Yes, this does have to do with scripting. I'm making a GUI, and at the bottom I have 3 image buttons. I want them each to take up 1/3 the width of the screen. Is there any way to find the size, or do I just have to experiment?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Aug 2016 10:36 AM
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local ScreenSizeX = mouse.ViewsizeX
local ScreenSizeY = mouse.ViewSizeY


Report Abuse
XxHockeyNinjaDugxX is not online. XxHockeyNinjaDugxX
Joined: 31 Jan 2013
Total Posts: 33
07 Aug 2016 11:01 AM
Same thing he said above
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local ScreenSizeX = mouse.ViewsizeX
local ScreenSizeY = mouse.ViewSizeY
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Aug 2016 11:24 AM
Don't even bother finding the size, just use scale instead of transform when creating the frame.
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Aug 2016 11:29 AM
To clarify, set the first frame's position to {{0,0},{0,0}} the second to {{0.33,0},{0,0}} and the third to {{0.66,0},{0,0}} This is not exactly a third but i think it should be close enough for you.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Aug 2016 11:31 AM
that sketchy. You need exact values

gui.Position = UDim2.new(0,ScreenSizeX/3,0,ScreenSizeY/3)


Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Aug 2016 11:36 AM
How is this sketchy?
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
07 Aug 2016 11:40 AM
It's inaccurate and bad practice.
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Aug 2016 11:44 AM
Please forgive me for being inaccurate, I didn't expect 0.00333333333... to be such a huge deal when creating a gui
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Aug 2016 11:44 AM
When we are talking about quality of a game, you can't just half ass it.


Report Abuse
Toonshield is online. Toonshield
Joined: 04 Mar 2015
Total Posts: 518
07 Aug 2016 11:46 AM
I'm actually as confused as him, what's wrong with scale if you want a 1/3rd of the screen? I'm not saying scale makes good guis, but if it's what you want, why script a pseudo-scaling gui?
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
07 Aug 2016 11:47 AM
^
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
07 Aug 2016 11:52 AM
"I'm not saying scale makes good guis"

and no one is saying offset makes good guis
Report Abuse
PhoenixSigns is not online. PhoenixSigns
Joined: 17 Sep 2011
Total Posts: 1137
07 Aug 2016 11:53 AM
The Width of a screen depends on the user's computer, or tablet.
It varies based on the screen size. It's better to use Scale for making guis.


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Aug 2016 11:54 AM
There is nothing wrong with scale. Just the solution I posted was a simpler way of going about it. I already have posted a way in the past where you can directly center a gui using scale.


Report Abuse
Color3new is not online. Color3new
Joined: 05 Jul 2009
Total Posts: 64
07 Aug 2016 11:54 AM
I'm bit confused here as well. Scale, as the name implies, scales to the size of the screen.

The way you're doing it here, you'd need a loop somewhere updating the viewsize, and you know that the more loops you have, you're stacking up on lag.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
07 Aug 2016 11:55 AM
notice the significant amount of black space on the right of the screen when using 0.33
gyazo.com/4906bcfbdd207ace18c9d1b09d98393f

as opposed to a more accurate third
gyazo.com/4497f49007753632c8ecf0e3fd19c27f
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Aug 2016 11:55 AM
woops i didnt mean that nvm


Report Abuse
Toonshield is online. Toonshield
Joined: 04 Mar 2015
Total Posts: 518
07 Aug 2016 12:03 PM
@Kodran

Using the most accurate I can go to (0.333) I got just a sliver on my screen.

http://prntscr.com/c2ql4c

Did you just use 0.3 or even 0.33? That seems intentionally dishonest if you did.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
07 Aug 2016 12:07 PM
I used 0.33

The different outcomes are because my screen is larger than yours, so a less accurate scale will make more difference for me in terms of number of pixels.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
07 Aug 2016 12:08 PM
By larger screen I don't mean physically larger, I just mean higher resolution.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
07 Aug 2016 12:11 PM
That black space is nearly triple the size when I span it across all monitors
gyazo.com/4906bcfbdd207ace18c9d1b09d98393f

Which proves you should never use inaccurate values, even if they look good for you because it may not look great for other people with different setups.
Report Abuse
Color3new is not online. Color3new
Joined: 05 Jul 2009
Total Posts: 64
07 Aug 2016 12:11 PM
Mine is larger as well and I get a large sliver. How is roblox determining gui scale?

Your way is definitely more accurate, just seems a bit of a pain considering that you'll have to update the screen size variables to consolidate for when you resize your window, since you're using offset.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
07 Aug 2016 12:11 PM
Sorry wrong picture
gyazo.com/c337fa7d4ea2fd6b11ab901d1ef096ab
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
07 Aug 2016 12:14 PM
Roblox is calculating scale perfectly. if you do 0.33*number of pixels you'll get exactly what 33% of the screen is. The problem is that isn't as accurate as dividing the number of pixels by 3.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image