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

Changing scale of a GUI based on an IntValue?

So I'm making a meter that will decrease along with an IntValue stored in the player.

When I try to do it this way:

meter.Size.Y.Scale = height

This odd error comes up:

Scale cannot be assigned to Script 'Players.Player.PlayerGui.existence.bg.meter_bg.meter.destru', Line 13 Stack End

But if I try it this way, the meter will stay completely blank:

meter.Size = UDim2.new({1, 0},{height, 0})

The maximum the value can be is 100, and the minimum is 0. So when I set the value of height, I have it set to the value stored in the player divided by 100, so I don't see why this isn't working.

I would appreciate any help, thanks for reading.

1 answer

✓ Accepted answer

The first error is because the definition .Size.Y.Scale is read-only, so you can only read the value of it with the script, not set it, so you need to set the Size to a UDim2 with UDim2.new

You don't use curly braces when defining a UDim2. Just input the 4 numbers as 4 separate arguments. UDim2.new(xScale, xOffset, yScale, yOffset)

1 comment

0

Thanks, that was part of the problem. I've sorted the rest of it out now, and it is working fine.

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