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 5 years ago
Edited 5 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:

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

2 answers

Log in to vote
0
Answered by 5 years ago

Do this instead

   if  script.Parent.Occupant then
        for i  = prog.Value, 5 do
        wait()
            prog.Value = tonumber('.' ..i)
        end
    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 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago
Edited 5 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 — 5y

Answer this question