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)

3 comments

0

When you do local num = amount() you are running the function. Set a global variable in the script instead of returning.

0

Thanks that works

0

@zymletal add [ANSWERED] to question's title