NPC shooting range routine

ok so im trying to make an npc in a shooting range go to an ammo box and refill, then go back to their orginal position, except it won’t no matter what i do :moyai:

script.Parent:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(script.Parent:WaitForChild("Animations"):WaitForChild("Idle")):Play()
wait(1.4)
local gun = script.Parent:WaitForChild("aiAK47")
local pfs = game:GetService("PathfindingService")
local spot = Instance.new("Part", workspace)
spot.Name = "Spot"
spot.Transparency = 1
spot.Anchored = true
spot.Position = script.Parent:WaitForChild("UpperTorso").Position
spot.CanCollide = false

while true do
	for c = 1, 30 do
		gun.Handle.Attachment.PointLight.Enabled = true
		gun.Handle.Attachment.ParticleEmitter:Emit(6)
		gun.Handle.Gunfire:Play()
		wait(0.02)
		gun.Handle.Attachment.PointLight.Enabled = false
		wait(0.3)
	end
	wait(1)
	local path = pfs:CreatePath()
	path:ComputeAsync(script.Parent.UpperTorso.Position, workspace.AmmoBoxPickupAI.Position)
	local wp = path:GetWaypoints()
	for i, wahfiu in pairs(wp) do
		script.Parent.Humanoid:MoveTo(wahfiu.Position)
		script.Parent.Humanoid.MoveToFinished:Wait(2)
	end
	wait(1)
	workspace.AmmoBox.Sound:Play()
	wait(3)
	path2 = pfs:CreatePath()
	path2:ComputeAsync(script.Parent.UpperTorso.Position, spot.Position)
	local wp2 = path2:GetWaypoints()
	for i, wahfiua in pairs(wp2) do
		script.Parent.Humanoid:MoveTo(wahfiua.Position)
		script.Parent.Humanoid.MoveToFinished:Wait(2)
	end
	wait(2)
end

help is greatly appreciated

not giving me answers?? asdfghjkl

Well you haven’t really provided much information.

Are there any errors? Have you tried debugging your self to see at which line the script stops executing?

at the start, the npc spawns, empties their mag, and goes to the ammo box to refill
what im trying to do is its supposed to return back to its shooting range area/spawn area, but its still stuck at the ammo box
i wrapped the function in question in a pcall but nothing pops up