I'm trying to make NPCS move to a block when an event is fired

The NPCS move between 4 blocks and I'm trying to make it so the NPCS start going to a different block when I fire the event, but it doesn't do anything, no errors.



game:GetService("ReplicatedStorage").Events.Run.OnServerEvent:Connect(function()
	
	local npcs = game.Workspace.NPCS:GetChildren()
	
	
	
	for i, v in pairs(npcs) do
		local anim = script.Animation
		local humanoids = v.Humanoid
		
		humanoids.Animator:Destroy()
		wait(0.25)
		local theanim = humanoids:LoadAnimation(anim)
		
		theanim:Play()
		
		humanoids.Parent.Script.Disabled = false
		humanoids:MoveTo(game.Workspace.Path.RunTo.Part1)
		humanoids.MoveToFinished:Wait()
		
		
		
		
	end
end)

This is the script inside the NPC, I tried disabling it as you can see


local hum = script.Parent:WaitForChild("Humanoid")
local anim = script:WaitForChild("Animation")
local move = script.Parent.Humanoid:LoadAnimation(anim)


script.Parent.Humanoid.WalkSpeed = 10
if script.Parent ~= nil then
	move:Play()
end

while wait(0.25) do
	script.Parent.Humanoid:MoveTo(game.Workspace.Path.Part3.Position)
	script.Parent.Humanoid.MoveToFinished:Wait()
	script.Parent.Humanoid:MoveTo(game.Workspace.Path.Part1.Position)
	script.Parent.Humanoid.MoveToFinished:Wait()
	script.Parent.Humanoid:MoveTo(game.Workspace.Path.Part4.Position)
	script.Parent.Humanoid.MoveToFinished:Wait()
	script.Parent.Humanoid:MoveTo(game.Workspace.Path.Part2.Position)
end

4 comments

0

Are you saying you have a loop that moves the npcs between 4 different parts? Are we missing some code here? Or is it just not moving to Part1 when the event is fired.

0

The NPCS move between 4 parts and when a user says "Infernal" In chat it fires the event and makes them move to part 1, but it doesn't do that

0

What do u mean it moves between 4 parts? Maybe some other script is overwriting your change?

0

It might be, I'll edit and add the script