Hello
I have made a script that is supposed to unanchor all parts in an NPC and make them move to a point. The NPC is an R16 model, and the only part anchored at the beginning of the game is the HumanoidRootPart. When I run the script, no error occurs, but all of the NPC’s hover in the sky. If I look in the explorer, all of the parts I wanted to unanchored are. I am also making the player move to the same point.
for i, v in pairs(game.Workspace.WorkMap.Soldiers.GunSoldiers:GetChildren()) do
if v.Name == "Soldier" then
v.HumanoidRootPart.Anchored = false
v.HumanoidRootPart.CFrame = CFrame.new(v.HumanoidRootPart.Position.X, v.HumanoidRootPart.Position.Y + 10, v.HumanoidRootPart.Position.Z) -- NPC's wont be stuck in an object
v.Gun:Destroy()
for a, part in pairs(v:GetChildren()) do
if part:IsA("Part") or part:IsA("MeshPart") then
part.Anchored = false -- Making sure all parts should be unanchored
end
end
end
v.Humanoid:MoveTo(playerPositions.SoldierMove1.Position) -- Move the NPC's to the point
end
game.Players.LocalPlayer.Character.Humanoid:MoveTo(playerPositions.SoldierMove1.Position) -- Move the player to the point
Here is a picture of what happens when I run the script:
Off in the distance, you can see that the player is moving to the point, but all of the NPC’s are hovering there. The one that is sitting down is not supposed to be moving, but the rest are. All the sandbags and parts in the NPC’s have CanCollide off, so they should not be getting stuck on anything.
Can anyone help me?