I want to create a “health” bar for an object, and when you click the object, the health bar will go down 1/4 of 200, which will result is 1/4 being remove from the health bar. And then, when the bar is on zero, the object gets destroyed.
I have an idea of how to destroy the object, create the GUI, add one the values, etc, etc but I just cant figure out how to change the size of the GUI by -50 each time.
Put the bar inside another frame for background.
What this calculation basicly does is dividing the current value by max.
This provides you with a value between 0 and 100% of the max value.
10 / 100 = .1
50 / 100 = .5
it also works when the max value is higher than 100
75 / 500 = .15
100 / 450 = .22222222
because you put it in the scale 1 = 100% of its parent size.
.5 will fill the bar 50%
Don’t do it in a server script, that will overload the server and cause tons of lag. Interacting with UI should be handled on the client and in some cases completely handled by the client.