i made this code, but idk how to check for nearby players pls help
local basenpc = {}
basenpc.__index = basenpc
function basenpc.new(npc)
local self = setmetatable({}, basenpc)
self.npc = npc
self.humanoid = self.npc.Humanoid
self.rootpart = self.npc.HumanoidRootPart
self.head = self.npc.Head
self.desiredInterval = 2.5
self.counter = 0
self.ticked = game:GetService("RunService").Heartbeat:Connect(function(...)
self:update(...)
end)
self:init()
return self
end
function basenpc:init()
end
function basenpc:update(dt, step)
self.counter = self.counter + step
if self.counter >= self.desiredInterval then
self.counter = self.counter - self.desiredInterval
-- execute stuff after interval
end
end
return basenpc