Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local PathfindingService = game:GetService("PathfindingService")
- local moveNPCEvent = ReplicatedStorage:WaitForChild("MoveNPCEvent")
- moveNPCEvent.OnServerEvent:Connect(function(player, targetPosition)
- local npc = game.Workspace:FindFirstChild("Test") -- тут надо поменять test на имя своего нпс
- if npc then
- local humanoid = npc:FindFirstChildOfClass("Humanoid")
- local humanoidRootPart = npc:FindFirstChild("HumanoidRootPart")
- if humanoid and humanoidRootPart then
- local path = PathfindingService:CreatePath({
- AgentRadius = 2,
- AgentHeight = 5,
- AgentCanJump = true,
- AgentJumpHeight = 7.5,
- AgentMaxSlope = 45,
- AgentMaxStepHeight = 2,
- AgentCanClimb = false,
- AgentCanSwim = false,
- Costs = {}
- })
- path:ComputeAsync(humanoidRootPart.Position, targetPosition)
- path.Blocked:Connect(function()
- humanoid:MoveTo(targetPosition)
- end)
- humanoid:MoveTo(targetPosition)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement