You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to spawn like 20 all at once and not once 30 times. I also want them to not spawn at 1 place only and maybe spawn in a formation? or something like that?
What is the issue? Include screenshots / videos if possible!
I don’t know how to do this because I’m pretty know so I don’t know how to script.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried searching google and forums
local rp = game:GetService("ReplicatedStorage")
local remote = rp:WaitForChild("Teleport")
local player = game:GetService("Players")
print("test1")
remote.OnServerEvent:Connect(function(player)
local character = player.Character.PrimaryPart
local function spawnsoldier()
local ssoldier = rp:WaitForChild("RomanSoldier")
local Soldier = ssoldier:Clone()
Soldier.Parent = game.Workspace
wait(0.4)
Soldier.HumanoidRootPart.CFrame = character.CFrame * CFrame.new(10,0,0)
end
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
spawnsoldier()
print("test2")
end)
you can use a for loop like @TenBlocke said. You can also make the soldiers root part position or CFrame random. Kinda like this
for count = 1, 30, 1 do
spawnSoldier()
if soldier.HumanoidRootPart THEN
soldier.HumanoidRootPart.CFrame = char.CFrame * CFrame.New{math.random(-10,10), char.Position.Y,math.random(-10,10))
end
end
this is pseudo code and probably wont work if you just copy and paste. I wrote it just to get you a general idea
EDIT: If you want the soldiers to spawn in a formation id assume youd have to look up some cframe formula
Are you referring to the fact one spawns, it waits a bit, and then it spawns another? According to your function, you have wait(0.4). That line right there is going to wait 0.4 seconds before it spawns another one. Try removing that, not sure if I’m understanding you correctly here.
I know I’m a bit late to this but can’t you just move the wait out of the function and to before the for loop? Moving it to before the for loop will make it have no delay and spawn after teleporting.