Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Am I doing Cframe correctly?

Asked by 7 years ago
Edited 7 years ago

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
0
Change your iterator function to pairs instead of ipairs. RayCurse 1518 — 7y
0
Did not work, but thanks. Alphaminusone 0 — 7y
0
You define the function MovePlane() but never actually call it. RayCurse 1518 — 7y

Answer this question