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

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
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

Ad

Answer this question