Trying to get the nearest object

It actually just prints an empty table!

1 Like

When I only print the nearestHook without .Name it still prints the name of the hook.

Ohhhh, I think I know the problem. The function is returning the primary part of the hook, not the hook itself.

Just take out the, .PrimaryPart

But now the hook is Workspace.Hooks.Hook and it should be Workspace.Hooks.Hook.Hook

I fixed it but the nearestPoint is nil

I think that’s because you’re defining nearestPoint as nil:

Try removing the “= nil” and only having “local nearestHook”

That’s what I do for my enemy AI scripts.

It will print the same as before. I’ve tested before.

I don’t think that I will need anymore help.