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

How can i set value on ScreenGui's AbsoluteSize?

I want to make a script for auto change ScreenGui's AbsoluteSize.
Just like this:

local Camera = workspace.CurrentCamera
local GuiScreen = game.StarterGui.ChooseYourPower
local CameraSize = Camera.ViewportSize

GuiScreen.AbsoluteSize = CameraSize

But it's says: can't set value
Any ways to make it can set value?
Thanks!

6 comments

0

AbsoluteSize is read only, it's basically the stored version of the size of it. You edit it from the Size property. Gui.Size = CameraSize

0

I tried. But ScreenGui has no Size.

0

"Size is not a valid member of ScreenGui."

0

It's the frame or elements within the ScreenGui that have sizes... You have to adjust those.

0

I'm not really understand. Can you say that again?

0

The ScreenGui is a mere placeholder for the elements that are to be resized to your liking. Frames, ImageLabels, TextLabels, TextButtons can all be resized.

1 answer

✓ Accepted answer

ScreenGui acts as a placeholder for resize-able objects within the PlayerGui.

You cannot resize ScreenGui objects directly, as they do not have a Size property. If you click on your SG and view it from the properties window, you will see that such a property does not exist.

Instead, it is required you fill your SG with other elements that are resize-able. Such elements include the following:

  1. Frame
  2. ScrollingFrame
  3. TextBox
  4. TextButton
  5. TextLabel
  6. ImageButton
  7. ImageLabel

Here is an example of a frame being resized and moved within an SG.

local Players = game:GetService("Players")
local PlayerGui = Players.LocalPlayer:WaitForChild("PlayerGui")

local ScreenGui = Instance.new("ScreenGui", PlayerGui)
local Frame = Instance.new("Frame", ScreenGui)
Frame.AnchorPoint = Vector2.new(0.5, 0.5)
Frame.Size = UDim2.new(0, 100, 0, 100)
Frame.Position = UDim2.new(0.5, 0, 0.5, 0)

However, if you wish to manipulate all the elements within a ScreenGui at once, this is possible using ROBLOX's fairly new UI constraint objects. If you wish to learn more about these, take a look at this.

Hope this answered your question.

1 comment

0

Ooh! i'll take this!! thank you!

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