How do i make ai that follows you but stops trying to follow the player when the player is dead since i made breakjointsondeath to false ,the ai just flings the player
i see alot of tutorials on yt but none of them make the ai stop following after the player is dead
Here is the script I dont remember who made this script but i remember taking this from a youtube video:
local ChaseRange = 1420
local AIHumanoid = script.Parent.Humanoid local AIHumanoidRootPart = script.Parent.HumanoidRootPart
local function GetClosestPlayer() local closestPlayer = nil local closestPlayerDistance = ChaseRange
for i,v in pairs(game.Players:GetPlayers())do
if v.Character then
local charHRP = v.Character.HumanoidRootPart
if (charHRP.Position-AIHumanoidRootPart.Position).Magnitude < closestPlayerDistance then
closestPlayer = v.Character
closestPlayerDistance = (charHRP.Position-AIHumanoidRootPart.Position).Magnitude
end
end
end
return closestPlayer
end
while true do task.wait()
local ClosestPlayer = GetClosestPlayer()
if ClosestPlayer then
AIHumanoid:MoveTo(ClosestPlayer.HumanoidRootPart.Position)
end
end

4 comments
Here is the script local ChaseRange = 1420 local AIHumanoid = script.Parent.Humanoid local AIHumanoidRootPart = script.Parent.HumanoidRootPart local function GetClosestPlayer() local closestPlayer = nil local closestPlayerDistance = ChaseRange for i,v in pairs(game.Players:GetPlayers())do if v.Character then local charHRP = v.Character.HumanoidRootPart if (charHRP.Position-AIHum
I can't read that. Could you put it in the description by using edit?
I edited it The first part didnt count as script so make sure to copy that also BTW I DONT REMEMBER WHO MADE THE SCRIPT
Oh! T3 already answered. Hope we both help!