I know the title may be vague, but there wasn't really any better way to explain it. Basically, I'm making a game that works in a round system (ROBLOX version of Trouble in Terrorist Town, if that helps). That is, pre-game, in-game, post-game, repeat.
But I noticed an issue. I made a server with four players in Studio and it crashes when the round ends, after a certain message.
Here's the snippet of code the error should be around:
local mapDir = game.ServerStorage.Maps
local newMap = mapDir:GetChildren()[math.random(#mapDir:GetChildren())]
local m = Instance.new("Message",game.Workspace)
m.Text = "New game starting with the "..newMap.Name.." map..."
wait(5)
m:Destroy()
newMap:clone().Parent = game.Workspace.Map
local newTraitors = choose_traitors(2)
for a,b in pairs(playerDir:GetChildren()) do
local val = Instance.new("IntValue",b)
val.Name = "traitor"
for c,d in pairs(newTraitors) do
if b == d then
val.Value = 1
break
end
end
end
for a,b in pairs(playerDir:GetChildren()) do
if b:findFirstChild("dead") then
b:findFirstChild("dead").Value = 0
end
end
in_game = true
script.in_game.Value = 1
end
The script crashes the pseudo-server after the m.Text = "New game starting with the "..newMap.Name.." map..." message displays for 5 seconds.
(if you need the choose_traitors() function, ask)

2 comments
Maybe it's the amount of parts you have in your maps (regarding line 11). I would like to see the 'choose_traitors()' function, but it might not be the problem.
Instead of cloning a whole map to Workspace, break up the map into different groupings and then check to see if the CFrame of each grouping is correct.