Why does the bar go to 0 instantly?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? A bar that sizes with a int value in a folder.

  2. What is the issue? The bar just goes black. Even if the int value is above 0.

  3. What solutions have you tried so far? Chatgpt, dev forums.

for _, player in ipairs(Players:GetPlayers()) do
local Bar = player.PlayerGui.GameInfo.Hunger
local Int = workspace.Values.Hunger
local Num = 1

while wait() do
	Int.Value = Int.Value - Num
	local IntSize = Int.Value
	local Size = UDim2.new(0, IntSize, 0, 0)
	Bar.Size = Size
	print(Size)
	end
end

Perhaps try waiting a few seconds before dropping a unit?

Having no wait, in a loop, will end as an instantly loop. This means, there is no time between those actions, you may not forget " wait(TIME) ".

Doesnt work, but I found a work around.

Don’t forget to do your task.wait(TIME), as this is better because it will run the first frame after the time has passed.

I said wait(Time) because both has wait, and I am using task.wait(). But I didn’t want to change the other persons mind, even though its better.

1 Like

Alright, I was just checking to make sure you’re not missing out on some resource benefits.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.