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

Movement Script doesn't move the NPC?

Asked by 7 years ago

In this script, it detects a player, then moves an NPC to it. Everything seems to be working, but the NPC doesn't move. What am I doing wrong?

01local larm = script.Parent:FindFirstChild("HumanoidRootPart")
02local rarm = script.Parent:FindFirstChild("HumanoidRootPart")
03 
04function findNearestTorso(pos)
05    local list = game.Workspace:children()
06    local torso = nil
07    local dist = 10000
08    local temp = nil
09    local human = nil
10    local temp2 = nil
11 
12 
13    for x = 1, #list do
14 
15        temp2 = list[x]
View all 43 lines...

Thanks!

1 answer

Log in to vote
0
Answered by
Galicate 106
7 years ago

Using standard pathfinding would work but would have some flaws. If you want to detect when a player joins a game a simple

[npcname].Humanoid:MoveTo(game.Players.[playername or localplayer])

but if you want it to move when the player gets a certain distance to it then a testfor a humanoid within a certain stud radius would work fine too.

Ad

Answer this question