RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"npc that follows me with roblox walk animations"
-- server script local PathfindingService = game:GetService("PathfindingService") local NPC = game.Workspace.NPC local animation = Instance.new("Animation") animation.AnimationId = "rbxassetid://507770453" -- Roblox walk animation ID local animator = NPC.Humanoid:LoadAnimation(animation) local function followPlayer(player) local path = PathfindingService:CreatePath() local target = player.Character.HumanoidRootPart.Position path:ComputeAsync(NPC.HumanoidRootPart.Position, target) for _, waypoint in ipairs(path:GetWaypoints()) do NPC.Humanoid:MoveTo(waypoint.Position) if waypoint.Action == Enum.PathWaypointAction.Jump then NPC.Humanoid.Jump = true end NPC.Humanoid.MoveToFinished:Wait() end end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() while true do followPlayer(player) wait(1) end end) end) NPC.Humanoid.Running:Connect(function(speed) if speed > 0 then animator:Play() else animator:Stop() end end)