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

uhhh, scale cannot be assigned to??????

Asked by 3 years ago
Edited 3 years ago

uh, i made a healthbar script that changes size in comparison to the players health and on the last line above end it says scale cannot be assigned to;

local player = game.Players.LocalPlayer
local health = player.Health
local Denominator = 100

wait(1)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

health.Changed:Connect(function()
    script.Parent.Frame.TextLabel.Text = health.Value .. " / " .. Denominator
    script.Parent.Frame.Size.X.Scale = health.Value / 100
end)

1 answer

Log in to vote
4
Answered by
Sparks 534 Moderation Voter
3 years ago

You cannot write to individual X/Y values of the Size. The Size is a UDim2 value, and therefore you must construct a new one of such.

local xScale = health.Value / 100
local xOffset = script.Parent.Frame.Size.X.Offset
local yScale = script.Parent.Frame.Size.Y.Scale
local yOffset = script.Parent.Frame.Size.Y.Offset
script.Parent.Frame.Size = UDim2.new(xScale, xOffset, yScale, yOffset) 
1
BRUH HOW IS THIS GUY ANSWERING EVERY QUESTION I MAKE XD CaIcuIati0n 246 — 3y
Ad

Answer this question