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 » Scripting Helpers
Home Search
 

Re: Getting the current size of the screen?

Previous Thread :: Next Thread 
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 08:40 PM
Without using mouse? Since I need to get it in a MouseButton1Down event in a gui
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
08 Apr 2013 08:45 PM
-- this belongs in a LocalScript
local gui -- assuming 'gui' is a GuiObject

gui.Size = UDim2.new(1, 0, 1, 0)
print(gui.AbsoluteSize)

http://wiki.roblox.com/index.php/AbsoluteSize_(Property)
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
08 Apr 2013 08:47 PM
^^
Last i tried doing that AbsoluteSize always returned 0,0...
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
08 Apr 2013 08:48 PM
AbsoluteSize always returns Vector2.new(0, 0) when not in the context of a LocalScript.
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 08:49 PM
Thank you, doom.
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
08 Apr 2013 08:51 PM
actually, i have a feeling that the AbsoluteSize property is broken. i'm too lazy to test it, though.
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 08:52 PM
Is there another way, then?
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
08 Apr 2013 08:54 PM
gosh just test it first will you. lol
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 08:59 PM
Haha just as sleepy as you are lazy :)
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 09:10 PM
There, I tested it. It works fine for localscript, but raises an error with a normal script:

Players.Player1.PlayerGui.ScreenGui.Frame.Script:2: attempt to concatenate field 'AbsoluteSize' (a userdata value)
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
08 Apr 2013 09:12 PM
actually that error shouldn't have anything to do with whether or not you're using a LocalScript or normal Script.

if you want to concatenate the AbsoluteSize value of a GuiObject to a string, you have to use the 'tostring' function. e.g.,

local gui -- some GuiObject

local s1 = "stuff"
print(s1 .. tostring(gui.AbsoluteSize))
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 09:13 PM
Just kidding. I actually managed to make an error in a two-lined script. It works in the regular script as well, for future reference.
My error?
print("Regular"..script.Parent.AbsoluteSize)

for localscript I omitted any string before the numbers, i just wrote regular to distinguish the two
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
08 Apr 2013 09:18 PM
lol, what are you guys doing?


local player = game.Players.LocalPlayer
local SizeOfScreen = player.PlayerGui.ScreenGui.AbsoluteSize
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 09:20 PM
b..bu.. but doom didn't say screengui had that property..
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
08 Apr 2013 09:21 PM
If you clicked on a ScreenGui object, you will see it's the 2nd property down...
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
08 Apr 2013 09:25 PM
Mm.. Yeah while we're inventing properties here why don't you just go ahead and add a "Disc" enum to FormFactor for us, that'd be great.

(Lol look it's a joke ^^^ *wink*)
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
08 Apr 2013 09:27 PM
Wait, is this sarcasm? Or you srs. That will actually give you your screen res.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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