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

[ANSWERED]"for" limit must be a number but it is?

Asked by 4 years ago
Edited 4 years ago

For limit is a number but it says it isn't

function amount()
    script.Parent.Parent.amount.Visible = true
    script.Parent.Parent.amount.OK.MouseButton1Click:Connect(function()
        script.Parent.Parent.amount.Visible = false
        return tonumber(script.Parent.Parent.amount.input.Text)
    end)
end

function commands()
    local num = amount()
    local cmd = script.Parent.Parent.bar.Text
    if cmd == "cmds" then
        print("commands: \n cmds \n test")
    elseif cmd == "test" then
        for i=1,num do
            print("hi")
            wait(0)
        end
    end
end

script.Parent.MouseButton1Click:Connect(commands)
0
When you do local num = amount() you are running the function. Set a global variable in the script instead of returning. uhi_o 417 — 4y
0
Thanks that works zymletal 37 — 4y
0
@zymletal add [ANSWERED] to question's title Leamir 3138 — 4y

Answer this question