Hi there!
I'm working on a pathfinding script for an enemy in my game and i'd run into a bit of a problem.
I use a module script to access some important functions such as finding the closest target, a random target, and the function that we need right now: the one that creates the path towards the target.
here's what it looks like:
path:ComputeAsync(start, goal)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
return waypoints
else
return nil
end
so as you can see, if it creates a path, that's what it returns! all the waypoints. otherwise it returns nothing. the problem is, i've run into a situation where it returns something (in that specific scenario it returned a boolean) and because it wasn't a table, the NPC's script broke!
here's why (the NPC's script):
if returnedWaypoints ~= nil and #returnedWaypoints > 0 then
if it returns something other than a table it'll break because i can't do #returnedWaypoints on anything other than a table!
so my question is; how do i check if returned value is a table? i've tried to look up a few ways using type() and typeof() but i couldn't find anything useful ;w;
thanks in advance! any ideas are appreciated <3

1 comment
thank you! i can't test it out right now but when i do and make sure it works I'll accept your answer ASAP!