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

How to change a GUI's size from script? (Offset cannot be assigned to)

Asked by 6 years ago

plr = game.Players.LocalPlayer while true do script.Parent.Size.X.Offset = plr.Character.Humanoid.Health * 4 --the parent of this script is the gui wait(.1) end
0
You'll need to set all of the guis size. User#19524 175 — 6y
0
To add onto ^, the 'X' property is read-only, meaning you cannot set it to a new value. You need to set the whole thing (i.e. script.pt.Size = UDim2.new(0,0,0,0) ) ScrewDeath 153 — 6y
0
Thank you guys! GodOfRBLX 21 — 6y
0
script.Parent.Size = Udim2.new(plr.Character.Humanoid.Health * 4, 0, 1, 0) -- This should work profak 15 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Here is the correct code:


plr = game.Players.LocalPlayer

while true do script.Parent.Size = UDim2.new(0,plr.Character.Humanoid.Health * 4,1,0) wait(.1)

end

The second place in the UDim2.new is for offset, while the first is for scale. Hope this helped...

Ad

Answer this question