AI Script Review


local Color = Color3.new(255,255,255)
local Size = Vector3.new(0.6, 0.6, 0.6)

local function chase()
	--compute and get waypoints
	path:ComputeAsync(rootdemo.Position, destination.PrimaryPart.Position)
	local waypoints = path:GetWaypoints()
	--loop through waypoints and visualize
	for _, waypoint in pairs(waypoints) do
		local part = Instance.new("Part")
		part.Shape = "Ball"
		part.Material = "Neon"
		part.Color = Color
		part.Size = Size
		part.Position = waypoint.Position
		part.Anchored = true
		part.CanCollide = false
		part.Parent = game.Workspace
		--move to the waypoints
		demohumanoid:MoveTo(waypoint.Position)
		demohumanoid.MoveToFinished:Wait()
	end
end

Small tip for the code to run faster, make the anything.new(23,23,23) items local variables outside of the loop so that it can just quickly read a value, rather than having to create a new one every cycle of the loop

Source, and for more tips: The Basics Of Basic Optimization

1 Like