Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make my horde of npcs spawn behind the player?

Asked by 2 years ago
Edited 2 years ago

So basically, I'm making an ability for a sword where you can spawn a horde of noobs behind the player that will move straight ahead. I'm having a problem, though. That problem is that I can't figure out how to make them properly spawn behind the player, because when they spawn, they dont go where i want it to (The npcs are inside a model) Instead, their torso stays in the same place, but their arms and legs go in the direction they should be facing, which looks really weird. If needed, i can elaborate. One more thing, the noobs are in a square formation. Thanks!

Here is the script:

local noobs = game.ServerStorage.Noobs

game.ReplicatedStorage.NoobSummon.OnServerEvent:Connect(function(player)
    local debounce = false
    local char = player.Character
    local sword = char:FindFirstChild("NoobSword")

    wait(.2)

    local Noob = noobs:Clone()
    Noob.Parent = workspace

    Noob:MoveTo(char.HumanoidRootPart.Position)

    for i,v in pairs(Noob:GetChildren()) do
        if v.Name == "Noob" then
            v.HumanoidRootPart.Orientation = char.HumanoidRootPart.Orientation
            v.HumanoidRootPart.CFrame = v.HumanoidRootPart.CFrame * CFrame.new(0,-3,-20)
            v.HumanoidRootPart.Anchored = true
        else
            v.CFrame = v.CFrame * CFrame.new(0,-3,-20)
            v.Orientation = char.HumanoidRootPart.Orientation
        end
    end
end)

Answer this question