Help with keeping moving npcs in a formation

I’m trying to create a system where you have a group of npcs that follow the players mouse but for some reason its not orientating correctly. I want them to stay in a formation like this behind the front one.
image
the problem is that when they move on a different axis they go like this.
image

localscript

local Plr = game.Players.LocalPlayer

local Mouse = Plr:GetMouse()

Mouse.TargetFilter = game.Workspace.MTF

game:GetService(“RunService”).RenderStepped:Connect(function()

game.ReplicatedStorage.MoveMTF:FireServer(Mouse.Hit.Position)

end)

serverscript

game.ReplicatedStorage.MoveMTF.OnServerEvent:Connect(function(Plr, MousePosition)
local function GroupRoam()
local MTF1 = game.Workspace.MTF.MTF1
MTF1.Humanoid:MoveTo(MousePosition)
local MTF2 = game.Workspace.MTF.MTF2
MTF2.Humanoid:MoveTo(MousePosition + Vector3.new(-2.5,0,2.5))
local MTF3 = game.Workspace.MTF.MTF3
MTF3.Humanoid:MoveTo(MousePosition + Vector3.new(2.5,0,2.5))
local MTF4 = game.Workspace.MTF.MTF4
MTF4.Humanoid:MoveTo(MousePosition + Vector3.new(-2.5,0,5))
local MTF5 = game.Workspace.MTF.MTF5
MTF5.Humanoid:MoveTo(MousePosition + Vector3.new(2.5,0,5))
end

GroupRoam()
end)

1 Like

You could try making a primary dummy. What I mean by this is that the primary dummy will follow the mouse, and then the other dummies will move to a CFrame relative to the main dummy. (ex. MainDummy.HumanoidRootPart.CFrame - CFrame.new(number, number, number)). Then just convert this to Vector3

that’s what I did before I changed them all to mouse position and yet it didn’t fix it

You can make the vector in object space relative to the leader.

local MTF1_HumanoidRootPart = game.Workspace.MTF.MTF1.HumanoidRootPart

MTF2.Humanoid:MoveTo(MousePosition + MTF1_HumanoidRootPart .CFrame*Vector3.new(-2.5,0,2.5))
--repeat for each
2 Likes

It’s better than before but still doesn’t work entirely. the second one overtakes or switched side when it turns