Just checked on my project and worked perfect tysm for all the help!
Exact code in case anyone ever needs to use it:
{code}
--when bullet and enemy touch
for i,v in ipairs(listOfBullets) do
for i2, v2 in ipairs(listOfEnemies) do
BuEn = detectCollision(v.x,v2.x,v.y,v2.y,20)
if BuEn == true then
table.remove(listOfBullets, i)
table.remove(listOfEnemies, i2)
end
end
--collision function
function detectCollision(x1, x2, y1, y2, sens)
if math.abs(x1 - x2) < sens and math.abs(y1 - y2) < sens then
return true
else
return false
end
end
{/code}
And the tutorial I used to learn class and object stuff is this (
https://sheepolution.com/learn/book/14)
Thank you for everyone who helped in this post!