Okay it was like 1 in the morning when I wrote this so sorry if it looks terrible but the script is a roaming script for a humanoid that tells it to move to a node on the map once the magnitude between the npc and the node are less than 3 I want it to go to the next node and then make that check until it gets within 3 studs of that node...
--roaming script by darrion22
local human = script.Parent.Humanoid
local torso = script.Parent.Torso
local running = false
local Print = print
local Node1 = game.Workspace.Node1
local Node2 = game.Workspace.Node2
local Node3 = game.Workspace.Node3
local Node4 = game.Workspace.Node4
local Node5 = game.Workspace.Node5
-- Don't code while tired kids
local mag = (torso.Position - Node1.Position).magnitude
local mag2 = (torso.Position - Node2.Position).magnitude
local mag3 = (torso.Position - Node3.Position).magnitude
local mag4 = (torso.Position - Node4.Position).magnitude
local mag5 = (torso.Position - Node5.Position).magnitude
local moved1 = false
local moved2 = false
local moved3 = false-- don't recall why I put this in
local moved4 = false
local moved5 = false -- or this one
while wait(1) do
if running == true then
print("Script is running")
else
running = true
human:MoveTo(Node1.Position)
Print('moving to Node1')
if mag <= 3 then
moved1 = true
human:MoveTo(Node2.Position)
Print('moving to Node2')
if mag2 <= 3 then
human:MoveTo(Node3.Position)
Print('moving to Node3')
if mag3 <= 3 then
human:MoveTo(Node4.Position)
Print('moving to Node4')
if mag4 <= 3 then
human:MoveTo(Node5.Position)
Print('moving to Node5')
if mag5 <= 3 then
end
end
end
end
end
end
end
-- why can't I have coffee

2 comments
Okay I thought so sorry for it being ugly I was tired af and didn't realize what I was doing
he still only gets to the first node then stops