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

How can i upgrade my script because its laggy?

Asked by 5 years ago

So , i have a IA script for my NPC , the script create a routine for the NPC , like when its 8 am do that ... The problem is that sometimes the NPC want to do 2 things at the same times and i dont know why .. So if u can help me with my script thx :)

Code:

local pathService = game:GetService("PathfindingService")



local finish = workspace.ici


function followPath(path)

local points = path:GetWayPoints()

for index, point in pairs(points) do

if point.Action == Enum.PathWaypointAction.Walk then

script.Parent.Humanoid:MoveTo(point.Position)

script.Parent.Humanoid.MoveToFinished:Wait()

end

if point.Action == Enum.PathWaypointAction.Jump then

script.Parent.Humanoid.Jump = true

end

end

end



while wait() do

local getPath = pathService:ComputeRawPathAsync(script.Parent.HumanoidRootPart.Position, finish.Position, 500)

followPath(getPath)

end
0
while loops = lag Tweakified 117 — 5y

Answer this question