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

How can i set value on ScreenGui's AbsoluteSize?

Asked by 5 years ago
Edited 5 years ago

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!

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 TiredMelon 405 — 5y
0
I tried. But ScreenGui has no Size. MEndermanM 73 — 5y
0
"Size is not a valid member of ScreenGui." MEndermanM 73 — 5y
0
It's the frame or elements within the ScreenGui that have sizes... You have to adjust those. M39a9am3R 3210 — 5y
View all comments (2 more)
0
I'm not really understand. Can you say that again? MEndermanM 73 — 5y
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. T0XN 276 — 5y

1 answer

Log in to vote
0
Answered by
T0XN 276 Moderation Voter
5 years ago
Edited 5 years ago

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.

0
Ooh! i'll take this!! thank you! MEndermanM 73 — 5y
Ad

Answer this question