Like the title says, the NPC I am working on continuously moves the same speed, regardless of what its WalkSpeed is set to.
I’ve tried messing with the while true do wait() time, but that hasn’t worked, and now I am stuck.
This video shows it with 18 WalkSpeed:
This video shows it with 100 WalkSpeed:
here’s the script if anyone is curious:
-- Services
local Pathfinding_Service = game:GetService("PathfindingService")
-- Important variables --
local Enemy_Folder = script.Parent
local AI_Config = Enemy_Folder:WaitForChild("AI_Config")
-- NPC Variables --
local Enemy_Model = Enemy_Folder.Parent
local My_Root = Enemy_Folder.Parent:WaitForChild("HumanoidRootPart")
local My_Humanoid = Enemy_Folder.Parent:WaitForChild("Humanoid")
-- AI Configs --
local Agro_Distance = AI_Config:WaitForChild("Agro_Dist").Value
local Damage = AI_Config:WaitForChild("Damage").Value
local Speed = AI_Config:WaitForChild("Speed").Value
local Running_Animation = AI_Config:WaitForChild("Running_Animation").Value
local Walking_Animation = AI_Config:WaitForChild("Walking_Animation").Value
local Render_Speed = AI_Config:WaitForChild("Render_Speed").Value
local AI_Can_Jump = AI_Config:WaitForChild("AI_Can_Jump").Value
local AI_Can_Climb = AI_Config:WaitForChild("AI_Can_Climb").Value
local Path = Pathfinding_Service:CreatePath()
-- Bool Variables --
local Running = AI_Config:WaitForChild("Running")
local Walking = AI_Config:WaitForChild("Walking")
My_Root:SetNetworkOwner(nil)
while true do
task.wait()
for i,v in pairs(game.Workspace:GetChildren()) do
local root_part = v:FindFirstChild("HumanoidRootPart")
if root_part then
if (root_part.Position - My_Root.Position).magnitude <= Agro_Distance and v ~= Enemy_Model and not v:FindFirstChild("Enemy_Contents") then
print(v.Name.. " is within the distance of this NPC.")
Path:ComputeAsync(My_Root.Position, root_part.Position)
print(Path.Status)
if Path.Status == Enum.PathStatus.Success then
for i,c in pairs(Path:GetWaypoints()) do
My_Humanoid:MoveTo(c.Position)
end
end
end
end
end
end
Any advice given would be appreciated. I’m honestly stuck.