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

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


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

4 comments

0

You'll need to set all of the guis size.

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

0

Thank you guys!

0

script.Parent.Size = Udim2.new(plr.Character.Humanoid.Health * 4, 0, 1, 0) -- This should work

1 answer

✓ Accepted answer

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

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