Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Value reaches max instantly instead of gradually?

Asked by 6 years ago
Edited 6 years ago

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:

1while script.Parent.Occupant ~= nil do
2repeat
3    wait(.01)
4    prog.Value = prog.Value + 0.000000000001
5until
6    prog.Value >= 0.5
7    end
0
Idk but I noticed that your wait says ".01" maybe you have to add a zero like "0.01" aandmprogameing 52 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Do this instead

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

that should work

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. CaptainAlien132 225 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago

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

0
I need that loop or else it won't detect if the player is in the seat or not CaptainAlien132 225 — 6y

Answer this question