Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make NPC move from point A to Point B with trigger part? (Like jumpscare)

Hello, I am new to scripting and i need help with this script. I don't know why this script is not working. I made PartB and i have monster in Workspace (inside monster is only Humanoid and parts of monster) But when i put this script to TriggerPart it's not working.

Any help is appreciated! :o

local Monster =Script.Parent.Parent.Monster
local Animation =Monster.Humanoid:FindFirstChild('Animator')or instance.new('Animator',Monster.Humanoid)

Animation:LoadAnimation(Script.Animation)

Script.Parent.Touched:Connect(function()
      Monster.Humanoid:MoveTo(Script.Parent.Parent.PartB.Position)
      Animation:Play()
end)

1 answer

✓ Accepted answer
local Monster = Script.Parent.Parent:WaitForChild("Monster")
local Animation = Monster.Humanoid:FindFirstChild('Animator') or instance.new('Animator', Monster.Humanoid)

Animation:LoadAnimation(Script.Animation)

Script.Parent.Touched:Connect(function(hit)
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum then
		hum:MoveTo(Script.Parent.Parent.PartB.Position)
		Animation:Play()
	end
end)

try this also make sure ur monster isn't anchored

This discussion is preserved as it was. New answers, comments, and votes are closed.