Vexoyzzz
(Vexoyz)
March 25, 2024, 5:58pm
#1
Hello, ive made an npc walking ai but it doesnt seem to work and its breaks on this line below for some reason
for i, waypoint in pairs(workspace.Waypoints:GetChildren()) do
ive done some testing and found out that the script doesnt know what workspace.Waypoint is and its returning 0 on this line below
print(#workspace .Waypoints:GetChildren())
Could you show explorer, please?
xDelith
(xDelith)
March 25, 2024, 6:09pm
#3
Hi, what’s the error? Do you have a folder in workspace called Waypoints? If yes, is there anything inside the folder Waypoints?
Vexoyzzz
(Vexoyz)
March 25, 2024, 6:11pm
#4
heres the explorer (its a server script btw)
Qariter
(Mari)
March 25, 2024, 6:12pm
#5
Why not try workspace:WaitForChild(“Waypoints”)?
Vexoyzzz
(Vexoyz)
March 25, 2024, 6:17pm
#6
now it prints out 5 on the first time but if i run it again it just prints 0 again
WaitForChild is mostly never really necessary for server scripts.
Vexoyzzz
(Vexoyz)
March 25, 2024, 6:19pm
#8
nvm it got back to printing 0 again
Qariter
(Mari)
March 25, 2024, 6:19pm
#9
Check if they’re anchored, or check if they disappear in explorer while running it. Might be falling into the void.
It’s hard to tell whats going on without the full script.
Vexoyzzz
(Vexoyz)
March 25, 2024, 6:21pm
#10
theire there and anchored and i also tried the same with a module script before and got the exact same result
Print out the table and show output please
2112Jay
(2112Jay)
March 25, 2024, 6:48pm
#12
local points = workspace:WaitForChild("Waypoints")
for i, waypoint in pairs(points:GetChildren()) do
Vexoyzzz
(Vexoyz)
March 25, 2024, 7:38pm
#13
for some reason this time it worked thanks
Its because assets in the game haven’t loaded yet, that’s why you need to use :WaitForChild(), it waits for the item to load before continuing from its current point.
2112Jay
(2112Jay)
March 25, 2024, 10:22pm
#15
This line gave away what the problems was … like TomPlays63 said.
1 Like
system
(system)
Closed
April 8, 2024, 10:22pm
#16
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.