Welcome to my Website!

This is a paragraph! Here's how you make a link: Neocities.

Here's how you can make bold and italic text.

Here's how you can add an image:

Here's how to make a list:

To learn more HTML/CSS, check out these tutorials!

local Players = game:GetService("Players") local PFS = game:GetService("PathfindingService") local EnemyNPC = script.Parent local HRP = EnemyNPC:WaitForChild("HumanoidRootPart") local Humanoid = EnemyNPC:WaitForChild("Humanoid") local AGRO_DISTANCE = 30 local ATTACK_DISTANCE = 2 local function TargetPlayerNear() local Targets = {} -- Get all players within 30 studs HRPs in a table called Targets for i, player in Players:GetPlayers() do local char = player.Character local TargetHRP = char:WaitForChild("HumanoidRootPart") local distance = (HRP.Position - TargetHRP.Position).Magnitude if distance < AGRO_DISTANCE then table.insert(Targets, TargetHRP) end end -- Get the closest targethrp local closestdistance = math.huge local ClosestTarget = nil for i, targethrp in Targets do local distance = (targethrp.Position - HRP.position).Magnitude if distance < closestdistance then closestdistance = distance ClosestTarget = targethrp end -- Return the target player's HRP (object reference) return ClosestTarget end local function RunTowardsTargetPlayer(ClosestTargetHRP) local path = PFS:CreateAsyncPath(HRP.Position, ClosestTargetHRP.Position) local waypoints = path:GetWaypoints() for i, waypoint in waypoints do Humanoid:MoveTo(HRP.Position, ClosestTargetHRP.Position) wait(0.1) end end local function AttackTargetPlayer(PlayerHRP) local distance = (PlayerHRP.Position - HRP.Position).Magnitude if distance < ATTACK_DISTANCE then -- I don't know what to put yet, I forgot how to use raycast hitbox for melee weapons -- I had the NPC have the Scimitar and the Tool had DmgPoints and stuff -- I can't check the documentation I'm in school. print("AATTAAAAACK!!") end end local function MainLoopFunc() local Target = TargetPlayerNear() if not Target then return end RunTowardsTargetPlayer(Target) AttackTargetPlayer(Target) end while wait(0.3) do MainLoopFunc() end