NPC's doesn't change their positions on R6

I am using this Soldier NPC’s Pack in my game. However, when using a Script, they just stack up in one place (the Models location in ServerStorage) and don’t walk.

Here’s the Script:

                                for i = 1, 20 do
									local soldier = game:GetService("ServerStorage"):WaitForChild("Objects"):WaitForChild("Soldier"..math.random(1, 2)):Clone() --I renamed two of the Soldiers to 'Soldier'x based on their skin tone.
									soldier.Name = soldier.Name.."-"..math.random(1, 1000000)
									soldier:WaitForChild("HumanoidRootPart").Position = Vector3.new(-17, 25 + i, -12)
									soldier.Parent = game:GetService("Workspace"):WaitForChild("DynamicObjects")
								end
1 Like

soldier:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(Vector3.new(-17, 25 + i * 5, -12)) should work

yes you can, he literally said they were spawning in

You actually can. There is no errors and :WaitForChild("test"..noob), where noob is a string equal to “iamanoob”, will basically do a :WaitForChild("testiamanoob") action.

Luau is weird in the way that if you concatenate a number with a string it will usually auto tostring for you

Yeah I realized, I was using python earlier so eh.

Yeah I know, I know. I was just mixing python with lua. My bad.

Nope doesn’t work. They seem not changing the position at all.

@Soliform can you make a Baseplate where you test with the Script and the Soldiers?

The Soldiers does not work as I expected even when they exists (I’ve checked Explorer on Server Side and there was a lot of NPC’s in the Folder).

I am 100% sure they exists. Why would they not?

Here is updated code. You were incrementing on the Y axis, so it was just stacking up anyway. Here is the updated code, and result:

for i = 1, 20 do
	local soldier = game:GetService("ServerStorage"):WaitForChild("Objects"):WaitForChild("Soldier"..math.random(1, 2)):Clone() --I renamed two of the Soldiers to 'Soldier'x based on their skin tone.
	soldier.Name = soldier.Name.."-"..math.random(1, 1000000)
	soldier:WaitForChild("HumanoidRootPart").Position = Vector3.new(-17 + i * 5, 25, -12)
	soldier.Parent = game:GetService("Workspace"):WaitForChild("DynamicObjects")
end

It doesn’t fail… The soldiers Clone but they just don’t change their position and not move (I think that’s because NPC Script thinks that they are in the walls - there is a lot of them stacked up in one place).

Seems not to be working with Roblox NPC’s.

Can you grab a Roblox NPC Model and test the Scripts out because the normal Positioning Scripts doesn’t seem to be working for Roblox NPC’s (I think that the whole situation is caused by active NPC Script that probably moves the Soldier).

Seem to work fine on a baseplate. There’s something wrong with your map that messes with the Roblox pathfinding navmesh I think.
Edit: I noticed there are no animations playing. Are you sure your scripts inside the soldier are running?

Maybe that is because my game uses R6 that is required to run the guns. Wait… That’s not true. When I drag a single Soldier, it waits few seconds and after that - starts to move.

Edit: That’s true. They just sit in one position and chill until dragged away with Studio move tools. The only difference between R6 and R15 is that everything works fine on R15 but doesn’t on R6.

@Soliform

Try using SetPrimaryPartCFrame instead of just setting the position, i think setting the position of the rootpart in a r6 rig actually offsets it

Kinda interesting - when setting position Soldiers stacked up in one row. Now they are stacked in two rows and nothing other has changed. Here’s the most updated code:

for i = 1, 20 do
    local soldier = game:GetService("ServerStorage"):WaitForChild("Objects"):WaitForChild("Soldier"..math.random(1, 2)):Clone() --I renamed two of the Soldiers to 'Soldier'x based on their skin tone.
    soldier.Name = soldier.Name.."-"..math.random(1, 1000000)
    soldier:SetPrimaryPartCFrame(CFrame.new(-17 + i * 5, 25, -12))
    soldier.Parent = game:GetService("Workspace"):WaitForChild("DynamicObjects")
end

As someone said on devforum.roblox.com, I also tried using Model:MoveTo() but the effect was the same.

I don’t really know how to help because it’s a free model and I don’t really know how to fix it.

I discovered that when I change Position of any part of the Soldier’s body it just stays the same Position as it was.
The second discover is that when I deleted all Scripts and put them into the Model again, the Soldier equipped a gun.
@meow_pizza

The solution is very weird. I dragged Soldiers into the Workspace and then again to the Folder in Server Storage. It made the Soldiers working (somehow).