So, i'm working with a gui right now. I am trying to script a Udim2.new() script so that it changes the size of the GUI when certain event are activated.
But, whenever i test the game, it automatically sets the X-scale of the GUI to 1. Even tho i did not script it to be that way.
Can someone please help me?
Here's the code:
script.Parent.Size = UDim2.new(char.Humanoid.Health / char.Humanoid.MaxHealth,0,590,0,31)
The UDim2.new(number xScale, number xOffset, number yScale, number yOffset)
has a maximum of four parameters.
A scale has a maximum value of 1 and is a percentage of the player's screen. 1 being 100% of the screen size and 0 being 0% of the screen size.
Also to keep updating the health bar, you must use a while true do
loop.
Below, you will find a script that I think should solve your problem:
while true do wait() script.Parent.Size = UDim2.new((char.Humanoid.Health*0.1)/char.Humanoid.MaxHealth,0,0.02,0) end