for index, DexedDummy in pairs(Dummies) do
if index ~= LastDummy then
DexedDummy.Parent = game.ServerStorage
else
DexedDummy.Parent = workspace.Folder
end
end
worked out for me not sure what may be your issue with them not spawning in.
local Dummies = {
workspace.Folder.Dummy1,
workspace.Folder.Dummy2,
workspace.Folder.Dummy3,
workspace.Folder.Dummy4
}
local LastDummy = nil
game.Players.PlayerAdded:Connect(function(Player)
local Dummy
if LastDummy == nil then LastDummy = 1 end
Dummy = Dummies[LastDummy]
local Hum = Dummy.Humanoid
local UserId = Player.UserId
Hum:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(UserId))
for index, DexedDummy in pairs(Dummies) do
if index == LastDummy then
DexedDummy.Parent = workspace.Folder
elseif index ~= LastDummy then
DexedDummy.Parent = game.ServerStorage
end
end
task.wait()
LastDummy += 1
print(LastDummy)
end)
Okay, I actually constructed that sentence incorrectly. What I meant was that when there’s, for example, 1 player, there’s one dummy. When there are 2 players, there are 2 dummies, and so on. I apologize for my mistake.
-- please use getservice and not game.
-- this should be at the top of your script
-- `workspace` is an exception - it's ok to use
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
-----------------------------------------------
-- after the ApplyDescription
local playerCount = #Players:GetPlayers() -- get count of players
-- the idea is to make dummies appear as long as their index is below the amount of players
-- so dummy 4 would not appear with 3 players, but dummies 1,2,3 will
for index, DexedDummy in pairs(Dummies) do
if index <= playerCount then
DexedDummy.Parent = workspace.Folder
else
DexedDummy.Parent = ServerStorage
end
end
-- before the task.wait()
-----------------------------------------------