does anyone know why my ai doesnt move to me in game but it moves to me in studio
in game: https://gyazo.com/c17ff02ac6fd29e7d97e2c3b3562c605
IN STUDIO: https://gyazo.com/a9e7b713c9e901d66d02fb5153cd7ef5
also some swords are affected differently in game too based on damage?
ai script:
local pathfindingService = game:GetService('PathfindingService')
local humanoid = script.Parent.Humanoid
local torso = script.Parent.Torso
function doPath(startPos,endPos)
local path = pathfindingService:CreatePath()
path:ComputeAsync(startPos,endPos)
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait(2)
end
end
function findTarget()
local agroDistance = 500
local target = nil
for i,v in pairs(game.Workspace:GetChildren()) do
local human = v:FindFirstChild("Humanoid")
local torso = v:FindFirstChild("Torso")
if human and torso and v ~= script.Parent and v:FindFirstChild("DiedAward") == nil then
if (script.Parent.Torso.Position - torso.Position).magnitude < agroDistance then
agroDistance = (script.Parent.Torso.Position - torso.Position).magnitude
target = torso
end
end
end
return target
end
while wait(1) do
local torso = findTarget()
if torso then
--doPath(script.Parent.Torso.Position,torso.Position)
script.Parent.Humanoid:MoveTo(torso.Position)
script.Parent.Torso.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
humanoid.Jump = true
end
end)
end
end
this script is activated(enabled) 3 seconds after when the story scene is finished