Studio crashes when a round loads?
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:
01 | local mapDir = game.ServerStorage.Maps |
03 | local newMap = mapDir:GetChildren() [ math.random(#mapDir:GetChildren()) ] |
05 | local m = Instance.new( "Message" ,game.Workspace) |
06 | m.Text = "New game starting with the " ..newMap.Name.. " map..." |
11 | newMap:clone().Parent = game.Workspace.Map |
13 | local newTraitors = choose_traitors( 2 ) |
15 | for a,b in pairs (playerDir:GetChildren()) do |
16 | local val = Instance.new( "IntValue" ,b) |
18 | for c,d in pairs (newTraitors) do |
26 | for a,b in pairs (playerDir:GetChildren()) do |
27 | if b:findFirstChild( "dead" ) then |
28 | b:findFirstChild( "dead" ).Value = 0 |
33 | script.in_game.Value = 1 |
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)