-
What do you want to achieve? I have a script that makes the enemy walk towards waypoints using MoveTo in humanoid, i want to use something else than moveto
-
What is the issue? I heard that moveto has performance issues i wanna use a different method that gives less or no performace issue
i looked in dev forum but none helped me ig
function enemy.Move(enemy, map, movingToValue)
local humanoid = enemy:WaitForChild("Humanoid")
local offset = Vector3.new(math.random(-100, 100)/100, 0, math.random(-100, 100)/100)
local waypoints = map.Waypoints
if movingToValue == nil then
for waypoint=1, #waypoints:GetChildren() do
enemy.Config.MovingTo.Value = waypoint
repeat
humanoid:MoveTo(waypoints[waypoint].Position + offset)
until humanoid.MoveToFinished:Wait()
end
enemy:Destroy()
if enemy.Name ~= "Arrow" then
map.Base.Humanoid:TakeDamage(humanoid.Health)
TakeDamageEvent:FireAllClients()
end
else
for waypoint = movingToValue, #waypoints:GetChildren() do
enemy.Config.MovingTo.Value = waypoint
repeat
humanoid:MoveTo(waypoints[waypoint].Position + offset)
until humanoid.MoveToFinished:Wait()
end
enemy:Destroy()
if enemy.Name ~= "Arrow" then
map.Base.Humanoid:TakeDamage(humanoid.Health)
TakeDamageEvent:FireAllClients()
end
end
end
this is where i wrap move function to in another function coroutine.wrap(enemy.Move)(newEnemy, map)