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

X cannot be assigned to?

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

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.

4 comments

0

When I ran this, the Y size didn't change.

0

Please post an explaination with your answer; simply posting code doesn't help the answer solve their question.

0

Asker* Brain farts are lethal.

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.

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().

1 comment

0

So what should I have put in Line 1?

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