PathFinding Service Problem

Hey Devs I have a problem I have been trying to solve since morning I tried making a Path Finding Program for the NPC it didnt work I tried all sort’s of stuff including making it a Local Script it doesnt work I tried making a basic Hum move event And it still doest work look

local NPC = game.Workspace.ttignyemb
local Humanoid = NPC.Humanoid

Humanoid:MoveTo(game.Workspace.End.Position)

And also I tried this

--//SERVICE
local PFS = game:GetService("PathfindingService")

--//VARIABLES
local Character = game.Workspace.TestDummy
local Humanoid = Character:FindFirstChild("Humanoid")
local HRP = Character:FindFirstChild("HumanoidRootPart")
local TestDestination = game.Workspace.ChairTesting.Seat

local function moveToHumanoidToPart()
	Humanoid:MoveTo(TestDestination.Position)
end

moveToHumanoidToPart()
1 Like

Is the NPC unanchored? If it’s anchored, it won’t move. :slight_smile:

2 Likes

OMG it’s anchored lemme try and test it.

2 Likes

Ok now it works but The Model like falls apart so idk if I have to unachore everything in the model or just something

2 Likes

Cool! Is it a custom-made NPC? You could make use of the various constraint instances to keep it together or use WeldConstraint, that’d also keep it together but make it a lil hard if you wanted to animate it. Here’s some basic code to weld any model;

local function WeldModel(model,base)
	for i,v in ipairs(model:GetDescendants()) do
		if v:IsA('BasePart') and v ~= base then
			local Weld = Instance.new('WeldConstraint')
			Weld.Part0 = base
			Weld.Part1 = v
			Weld.Parent = base
			v.Anchored = false
		end
	end
	base.Anchored = false
end

WeldModel(workspace.Test,workspace.Test.PrimaryPart)
1 Like

But I don’t understand why I have to implement this tho cause what if in the future I want to animate it and stuff cause before it used to work without me having to do this.

1 Like

You should use Motor6Ds to Connect limbs and body parts, because they can be animated.

1 Like

Yes, I would definitely recommend Motor6Ds – they’re just a major pain to work with IIRC lol

1 Like

You saying the NPC used to stay together but later started falling apart?

1 Like

Is it an NPC like a Roblox character?

1 Like

Yes since I unachored it for it to move.

1 Like

Yes it is a Robloc character or model I imported.

1 Like

Well, if it’s a regular Roblox character, unanchoring it shouldn’t cause it to break into pieces unless the Motor6D’s were removed. If it was a model you imported, likely the only reason it stayed in place before was due to it all being anchored.

You’d have to go through and add Motor6D’s throughout it to hold it together if you’re wanting to animate this NPC :slight_smile:

2 Likes

You can use the PathfindingService to calculate a path from the NPC’s current position to the destination position, and then make the NPC follow the path by iterating through the waypoints and using Humanoid:MoveTo() to move to each waypoint Xx

1 Like

I have never heard of Motor6D WrollingYou

1 Like

They’re what Roblox uses for their character models essentially like joints. For example, the “neck” Motor6D connects the character’s head to their upper body;
image

There should be other topics out there which discuss them further in-depth and how to use them. :slight_smile:

2 Likes

I think you should research “motor6D”
if you want to connect body parts to the rig easily you should use the “RigEdit Lite” plugin

Note: if they shouldn’t be animated use welds

2 Likes