I made a animation and I used the default roblox animator.
When I test the walking animation it almost never plays. Somtimes it does. but most of the time it wont work
robloxapp-20230918-1033536.wmv (3.2 MB)
I tried making my own animator but I have no idea how to make a animator
I feel like its because of this pathfinding script:
local StartDist = 40
local Pfs = game:GetService("PathfindingService")
local Plrs = game:GetService("Players")
local RS = game:GetService("RunService")
local Waiet = false
local o = false
Path = Pfs:CreatePath({
AgentHeight = 5.5;
AgentRadius = 3;
AgentCanJump = true;
Costs = {
Water = 100;
DangerZone = math.huge
}
})
local Char = script.Parent
local Hum = Char:WaitForChild("Humanoid")
local waypoints
local NextWaypointIndex
local ReachedConnetion
local BlockedConnection
local function FindTarget()
local maxDistence = 80
local nearestTarget
for index, player in pairs(Plrs:GetPlayers()) do
if player.Character then
local target = player.Character
local distance = (Char.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude
if distance < StartDist and o == false then
o = true
script.Parent.StopIdle:Fire()
Char.Humanoid.WalkSpeed = 14
end
if distance < maxDistence then
nearestTarget = target
maxDistence = distance
end
if distance < 5 then
nearestTarget.Humanoid:TakeDamage(25)
end
end
end
return nearestTarget
end
local function FollowPath(destination)
local success, errormessage = pcall(function()
Path:ComputeAsync(Char.PrimaryPart.Position, destination)
end)
if success and Path.Status == Enum.PathStatus.Success then
waypoints = Path:GetWaypoints()
BlockedConnection = Path.Blocked:Connect(function(blockedWaypointIndex)
if blockedWaypointIndex >= NextWaypointIndex then
BlockedConnection:Disconnect()
FollowPath(destination)
end
end)
if not ReachedConnetion then
ReachedConnetion = Hum.MoveToFinished:Connect(function(reached)
if reached and NextWaypointIndex < #waypoints then
NextWaypointIndex += 1
Hum:MoveTo(waypoints[NextWaypointIndex].Position)
else
ReachedConnetion:Disconnect()
BlockedConnection:Disconnect()
end
end)
end
NextWaypointIndex = 2
Hum:MoveTo(waypoints[NextWaypointIndex].Position)
end
end
while wait() do
local Target = FindTarget()
if Target then
FollowPath(Target.HumanoidRootPart.Position)
end
end
what should I fix?
(Yes the animation proirity is movement)