Hi
Today while I was making the boss fight for my game I ran into an issue, which was that I need to be able to make an npc run away, but the issue is that the attack system that the npc is using seems to set Humanoid.WalkToPoint, so it bugs out the script I have with him running away. nothing happens in the output, and I've tried changing it to nil, vector3.new(nil, nil, nil), and vector3.new(0,0,0). the last one was the one the wiki said to do, but it just makes him run to 0,0,0.
my script is as follows for making the npc run.
local human = script.Parent.Humanoid
local reqhealth = 9950
while true do
wait()
if human.Health <= reqhealth then
print("damaged enough")
game.ReplicatedStorage.Events.BossLeaving:FireAllClients()
human.WalkSpeed = 35
script.Parent:FindFirstChild("AI"):Destroy()
human.WalkToPart = nil
--human.WalkToPoint = Vector3.new(0, 0, 0)
script.Parent:WaitForChild("Pathfind").Disabled = false
local door = game.Workspace.MazeDupe.BossArea.BossDoor
door.OpenDoor.Transparency = 0
door.OpenDoor.CanCollide = true
door.ClosedDoor.Transparency = 1
door.ClosedDoor.CanCollide = false
script.Parent.works.Value = true
human.MaxHealth = 1000000000
human.Health = 1000000000
else
human.WalkSpeed = 22
end
end
and the pathfind script is
local pathfindingservice = game:GetService("PathfindingService")
local ve = script.degrees
local endthing = script.vec
local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")
local myfirstray = Ray.new(torso.Position, Vector3.new(ve.Value))
local path = pathfindingservice:CreatePath()
path:ComputeAsync(torso.Position,endthing.Value)
local waypoints = path:GetWaypoints()
local function go ()
local path = pathfindingservice:CreatePath()
path:ComputeAsync(torso.Position,endthing.Value)
end
for i, waypoint in pairs (waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
human:ChangeState(Enum.HumanoidStateType.Jumping)
end
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(myfirstray, {torso})
if hit then
local path = pathfindingservice:CreatePath()
path:ComputeAsync(torso.Position,endthing.Value)
end
human:MoveTo(waypoint.Position)
human.MoveToFinished:Wait(1)
end
if you also need the player tracking script, let me know and I'll send it too.
If anyone has a solution to this, I'd be happy if you'd share your knowledge with me :)
thanks, have a nice day.
