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

Changing scale of a GUI based on an IntValue?

Asked by
novipak 70
10 years ago

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

Log in to vote
2
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

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)

0
Thanks, that was part of the problem. I've sorted the rest of it out now, and it is working fine. novipak 70 — 10y
Ad

Answer this question