Stamina bar doesnt show

hey there, basically. i have this script and a stamina bar GUI, the script and stamina works, but when i set the guis size ( players.LocalPlayer.PlayerGui.Stamina.Bar.Size = UDim2.new((current / max) * 0, 298, 0, 50) ) the bar just doesnt seem to work at all.

don’t steal my scripts >:(
2 Likes

You’re multiplying the (current / max) by zero (* 0) on line 25 which will always give zero no matter what the current and max variables are set to. Not sure if this is intended or not. It might be worth checking the effects of using scale and offset, and how you might go about calculating this values based on your current and max variables.

2 Likes

if i set the size to something else, the stamina bar works normally.

1 Like

Yes, because you are pretty much doing this:
players.LocalPlayer.PlayerGui.Stamina.Bar.Size = UDim2.new(0, 298, 0, 50)
when you multiply by zero.

1 Like

well, even removing that it still doesnt change anything.

1 Like

You shouldn’t remove it, but simply change the X Scale to something other than (current/max) * 0. I don’t know how your GUI is layed out, but do you might need to replace it with current/max instead.

1 Like

Hey so, when you create a UI, there is something called the “size offset” which would pretty much change the size of the UI depending on someone’s screen size. I suggest changing this to 0 to keep consistent sizing for all players.

Then, you would have the UI size to be a little smaller with the offset numbers. Then you would input those coordinates, and instead of (current/max) * 0 it would be current/max *(size of the UI)

1 Like

Also, you might need to split the script into a Client Sided and a Server Sided, to replicate the Stamina Bar as well as the Sprinting of the Player. (server would be the one handling the UI and the stamina bar whereas the client would handle the sprinting on Key Pressed)

1 Like

changing it to max/current makes the stamina bar extremely weird:

Yes that’s my mistake I must have mis-typed it. have you tried just removing the * 0 and having it as current/max by itself?

1 Like

that causes this:


that kinda works but… wha-

could you provide us with two UDim2 points:

  • the point where the bar is at its lowest
  • the point where the bar is at the highest

and then we can structure together the proportions for calculating the bar.

1 Like

highest (full stamina): {0.01, 298},{0, 50}
lowest (no stamina): {-0.299, 298},{0, 50}

Then you should be able to use UDim2.new(-(current/max)*0.3, 298, 0, 50)

1 Like

that works, but now the bar goes forward instead of backwards

yea my bad, here you go: UDim2.new(((current/max)*0.3)-0.3, 298, 0, 50)

1 Like