• Kickallbots function wont work.
    2 replies, posted
Hello, I tried today to use the player.CreateNextBot() function, which inserts the bot into a table, and also created a command to kick all bots using a for loop, code: [CODE] local bots = {} concommand.Add("blah_bot",function(ply) local b = player.CreateNextBot(botsName[math.random(#botsName)]) table.insert(bots,b) end) concommand.Add("blah_kickallbots", function() for _, v in pairs(bots) do v:Kick() table.Empty(bots) end end)[/CODE] but it only kicks one bot, and then the command doesnt work anymore at all. I dont know whats wrong?
move the table.Empty call to under the for loop. Better yet, remove the table.Empty call and use bots = {} under the for loop.
nvm its fixed, I just had to empty the table AFTER the for loop.
Sorry, you need to Log In to post a reply to this thread.