-
What do I want to achieve?
Working for loops. -
What is the issue?
For loops not working. -
What solutions have I tried so far?
Literally everything.
For some reason, my for loops are not working. I’ve looked everywhere for a solution.
for _, plr in pairs(players) do
plrpos[#plrpos + 1] = plr.Character.HumanoidRootPart.Position
end
for _,i in pairs(plrpos) do
posmagnitude[#posmagnitude + 1] = (nb.HumanoidRootPart.Position - plrpos).Magnitude
end
for _,i in pairs(posmagnitude) do
minmagnitude = math.min(posmagnitude, i)
end
for i,_ in pairs(posmagnitude) do
if minmagnitude == i then
TARGET = players[i]
break
end
end
All the tables and variables(assigned in the loops) are nil. The loops do not run at all.
There are no errors other than all variables being nil.