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

Why doesn't my NPC which is supposed to walk to the player goes to the wall instead?

Asked by 5 years ago

So basically I have script located inside an NPC's head which is supposed to make him walk to the player (1 player server btw). However, he instead goes straight for the wall. Could somebody help me fix this problem please?

Script:

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
while true do
wait(.1)
script.Parent.Parent.Humanoid.WalkToPoint = Vector3.new(char.HumanoidRootPart.Position)
end
end)
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Using WalkToPoint makes the Humanoid move from its current Vector3 position to the Vector3 position provided by WalkToPoint. This causes the Humanoid to run in a straight line, regardless of what is in its way.

There is pathfinding in Roblox, however it requires more scripting. https://developer.roblox.com/articles/Pathfinding Here is a link that will hopefully teach you more about it. I feel that it is explained well enough for me to not go into detail. Best of luck!

Ad

Answer this question