I have a turret script that's not working, it's supposed to shoot at something if it can find a target every second (ShotDelay) where shootAtNearest() is the function to shoot the nearest torso, Gun is the gun itself and debounce is false.
the code:
while true do
if findNearestTorso(Gun.Position) ~= nil then
shootAtNearest()
wait(ShotDelay)
else
wait(0.2)
end
end
Just a side note, I have multiple functions being declared before this, that piece of code is placed at the absolute end of the script. I have tested the functions individually and they work fine. |