You are using two different scripts?
No same extract scripts for both
You should have a different script for both. Because your script is only getting one teddy not both so only one teddy is working.
I made a new thing called waypoint2 and named the glitched one teddy1 changed the things in the script and heās still acting dumb
Lol now there both acting stupid greats
Are you trying to make them attack people or move to different spots?
Both I have another ai that works perfectly in a maze and he follows people when they get near and does everything but I copied and pasted the script from him into these guys it works for a little but then goes stupid
Idk why the quality is so bad I can retake if u want
Can u see the vid or still no I will try to fix if not
Could you zoom in a bit more please?
Can you see the video or no cuz idk why is aināt working
It might be because of this.
function patrol()
local waypoints = workspace.waypoints1:GetChildren()
local randomNum = math.random(1, #waypoints)
walkTo(waypoints[randomNum])
end
while wait(0.1) do
patrol()
end
The second it sees somebody it tells them to go back. Because you are waiting .1 seconds
But it sees no one in testing mode unless a humanoid in a model counts as one but I donāt think so
try this
local teddy = script.Parent
local humanoid = teddy.Humanoid
teddy.PrimaryPart:SetNetworkOwner(nil)
local function canSeeTarget(target)
local origin = teddy.HumanoidRootPart.Position
local direction = (target.HumanoidRootPart.Position - teddy.HumanoidRootPart.Position).unit * 230
local ray = Ray.new(origin, direction)
local hit, pos = workspace:FindPartOnRay(ray, teddy)
if hit then
if hit:IsDescendantOf(target) then
return true
end
else
return false
end
end
local function findTarget()
local players = game.Players:GetPlayers()
local maxDistance = 390
local nearestTarget
for index, player in pairs(players) do
if player.Character then
local target = player.Character
local distance = (teddy.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude
if distance < maxDistance and canSeeTarget(target) then
nearestTarget = target
maxDistance = distance
end
end
end
return nearestTarget
end
local function getPath(destination)
local PathfindingService = game:GetService(āPathfindingServiceā)
local pathParams = {
["AgentHeight"] = 15,
["AgentRadius"] = 4,
["AgentCanJump"] = false
}
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(teddy.HumanoidRootPart.Position, destination.Position)
return path
end
local function attack(target)
local distance = (teddy.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude
if distance > 70 then
local canSeeTarget = true
humanoid:MoveTo(target.HumanoidRootPart.Position)
else
local canSeeTarget = false
local attackAnim = humanoid:LoadAnimation(script.Attack)
attackAnim:Play()
target.Humanoid.Health = 0
end
end
local function walkTo(destination)
local path = getPath(destination)
if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
local target = findTarget()
if target and target.Humanoid.Health > 0 then
print("TARGET FOUND", target.Name)
attack(target)
break
else
print("Moving to ", waypoint.Position)
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
else
humanoid:MoveTo(destination.Position - (teddy.HumanoidRootPart.CFrame.LookVector * 10))
end
end
function patrol()
local waypoints = workspace.waypoints1:GetChildren()
local randomNum = math.random(1, #waypoints)
walkTo(waypoints[randomNum])
end
while wait(0.1) do
if not (canSeeTarget) then
patrol()
end
end
They donāt move anymore they just stand there
try this
while wait(0.1) do
if (canSeeTarget) then
patrol()
end
end
If this doesāt work then copy the other monster from the maze and use that.
Still donāt work I think itās just the game cuz my other model with the same script works and thereās multiple monster walking around it to