This is a script for an AI drone. The drone is supposed to slowly glide to the position of the player. However, nothing happens. There is no errors in the output.
local Vehicle = game.Workspace.AIVehicles.AIPlane
range = 200 -- the range that it attacks you from
while true do
wait(.1)
plrs = game.Players:GetChildren()
for i,plr in ipairs(plrs) do
if plr.Character ~= nil then
head = plr.Character.Head
if (Vehicle.Position - head.Position).magnitude <= range then
local GoTo = head.Position
local Speed = 2 --How many studs to move at a time.
local Debounce = false
local Direction = CFrame.new(Vehicle.Position, GoTo).lookVector
function MovePlane()
if Debounce then return end
Debounce = true
Vehicle.CFrame = Vehicle.Cframe + (Direction * Speed)
wait (0.2)
end
Debounce = false
end
end
end
end

3 comments
Change your iterator function to pairs instead of ipairs.
Did not work, but thanks.
You define the function MovePlane() but never actually call it.