It's supposed to make the NPC check if food is nearby, however when I move the food out of the workspace or delete it and call the function again it still says there is food nearby. Can't figure out why, I would appreciate some help with this issue!
function FindResource(Type)
local Head = script.Parent.Head
for i, v in pairs(game.Workspace.Resources:GetChildren()) do
if v then
if v.Name == Type then
if (v.Position - Head.Position).magnitude <= 50 then
print("Found Food")
end
end
end
end
end

1 comment
This script in the NPC is a server script, right? Are you deleting things locally from the client context? If so, they're still there on the server.