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

X cannot be assigned to?

Asked by 8 years ago

Hi guys! I made this code:

script.Parent.Size.X = UDim.new(1/4.5,0)
script.Parent.Size.Y = UDim.new(0,script.Parent.AbsoluteSize.X)
script.Parent.Position = UDim2.new(0,script.Parent.AbsoluteSize.X/2,0,1/45)

And I got this Output error:

00:41:16.160 - X cannot be assigned to 00:41:16.161 - Script 'Players.Player.PlayerGui.MenuGui.Frame.Frame.ImageLabel.LocalScript', Line 1 00:41:16.161 - Stack End

Why? What I wanted to do is that a gui is a scaled square (That means it shows up as a square on any screen size) and a tenth of it's size away from the parenting frame.

2 answers

Log in to vote
2
Answered by
Vezious 310 Moderation Voter
8 years ago
script.Parent.Size = UDim2.new(1/4.5,0,0,script.Parent.AbsoluteSize.X)
script.Parent.Position = UDim2.new(0,script.Parent.AbsoluteSize.X/2,0,1/45)

ROBLOX Lua doesn't let you edit the X without changing everything else. So you have to do double the work and edit the Y too & Vice Versa.

0
When I ran this, the Y size didn't change. fahmisack123 385 — 8y
0
Please post an explaination with your answer; simply posting code doesn't help the answer solve their question. User#6546 35 — 8y
0
Asker* Brain farts are lethal. User#6546 35 — 8y
0
The Y size is the object's X AbsoluteSize. If it didn't change that is your error. I put what you wanted to assign Y to. Vezious 310 — 8y
Ad
Log in to vote
-1
Answered by 8 years ago

The X and Y value of the size is a final property, it can't be changed but can only be read. But if it did work you were doing it wrong anyway. X and Y has 2 properties called Offset and Scale. You didn't specify which. The only way to change the size of a 2D element is by using UDim2.new().

0
So what should I have put in Line 1? fahmisack123 385 — 8y

Answer this question