local function PickingPlayerToBeZombie() wait(.1) for i,v in pairs(Players) do --Players is a table, not game.Players:GetChildren() local position = 0 position = position+1 if v == ChosenPlayerToBeZombie then --v = chosen player for i,q in pairs(ZombiesLastRound) do --q = player who was zombie last round if q ~= v then print(q) print(v) table.remove(Players,position) position = position-1 for i=1,#ZombiesLastRound do table.remove(ZombiesLastRound,i) end table.insert(ZombiesLastRound, v) else print("picking another player") PickingPlayerToBeZombie() end end end end end
What I think is wrong with this is that when q == v then it runs the function on a loop since it picks from the 'Players' table, and it always picks the first item in that table. So how would I make it so that if q == v, then the next time the function runs, it starts at a different position from the 'Players' table. Sorry, this is kinda hard to explain. This might not even be the problem, but I can't see what else it could be.