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

Basic Scripter here, I need help With this Function, Whats Wrong ???

Asked by 7 years ago

I'm trying to make it increase one every sec but when at 10 it goes back to zero

function ifit()
    while wait do
        NUM = 1
        Answer = NUM + 1
    end
    if Answer == 10 then
        Answer = 0
    end
end

ifit()

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You can use the break function

function ifit()
    while wait() do
        NUM = 1
        Answer = NUM + 1
        if Answer == 10 then
            Answer = 0
            break
        end
    end
end

ifit()

If that does not work, you could try the repeat function.

local NUM = 0
local Answer = 0 

function ifit()
    NUM = 1
    repeat
        wait()
        Answer = NUM + 1
        NUM = Answer
        print(Answer)
    until Answer == 10
end

ifit()
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I'm typing this on phone right now so ignore any typos, but, you can simply just do this:

answer = 0
function ifit()
if answer == 0 then
     for i = 0, 10 do
           answer = i 
           wait(1)
     end
end
wait(11)
if answer == 10 then
     answer = 0
 end
end

while true do
wait(11)
ifit()
end

If you already know what this does, great! Just contact me on roblox if you need an explanation. My username is: ioserswinger Also please note, I'm not very advanced yet either

0
username on my profile is wrong btw Speedracerpro -4 — 7y

Answer this question