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

Value reaches max instantly instead of gradually?

I'm trying to make it so there's a sort of "Sleep bar" that gradually falls, and to regain it you have to sleep. The bar goes down, but it instantly goes all the way up, instead of slowly rising. Here's the snippet:

    while script.Parent.Occupant ~= nil do
	repeat
		wait(.01)
		prog.Value = prog.Value + 0.000000000001
	until
		prog.Value >= 0.5
		end
	

1 comment

0

Idk but I noticed that your wait says ".01" maybe you have to add a zero like "0.01"

2 answers

Do this instead

   if  script.Parent.Occupant then
		for i  = prog.Value, 5 do
		wait()
			prog.Value = tonumber('.' ..i)
		end
	end

that should work

1 comment

0

It doesn't work the first time. You have to get out and back in for it to work, also once you leave the script still runs.

You have a loop through a loop so I would get rid of one of those and make sure it is waiting longer because the way you have it set, it looks like it will fill pretty fast. I would do: local count = 0 while (there is somebody in the bed AND count <= 5) do wait() --To make sure the loop is slowed down count++ --Do something else end

1 comment

0

I need that loop or else it won't detect if the player is in the seat or not

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