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()
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)
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.
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
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
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;
There should be other topics out there which discuss them further in-depth and how to use them.