The script (posted below) will freeze the server and I don't see why. This code is part of my Build Battle game, so after it is resolved I will censor it, but only because I don't want people stealing my game.
01 | function doSpecialRound(buildTime, voteTime, intermissionTime) |
02 | throw( "notification" , "This round will be different!" ) |
03 | wait( 11 ) |
04 | throw( "notification" , "This round you will have to guess what the player is building" ) |
05 | setStatus( "Choosing builder..." ) |
06 | wait( 3 ) |
07 | player = get_Child(game.Players,math.random( 0 ,#game.Players:GetChildren())) |
08 | if player.Character and player.Character.HumanoidRootPart then |
09 | player.Character:MoveTo(workspace.Teleports.LobbyBase.base.Position) |
10 | end |
11 | -- Give tools |
12 | for i,v in pairs (game.ServerStorage.StamperTools:GetChildren()) do |
13 | tool = v:Clone() |
14 | tool.Parent = player.Backpack |
15 | end |
EDIT (1):
1 | local get_Child = function (obj,index) |
2 | return obj:children() [ tonumber (index) ] |
3 | end |
Pretty sure its got to do with the while loop on line 45, no idea what you are trying to do in this loop but its wrong.
For instance, you use i as your timer number but also reuse it in a for loop on line 47 (for i,v) so the timer version of i never gets subtracted from because you only subtract within this loop. Rename one of the i's.
Also line 38, :disconnect is deprecated but :Disconnect() isn't so if you wanna change that.
Alright, so the problem still occurs, and here is the revised code:
01 | function doSpecialRound(buildTime, voteTime, intermissionTime) |
02 | throw( "notification" , "This round will be different!" ) |
03 | wait( 11 ) |
04 | throw( "notification" , "This round you will have to guess what the player is building" ) |
05 | setStatus( "Choosing builder..." ) |
06 | wait( 3 ) |
07 | player = get_Child(game.Players,math.random( 0 ,#game.Players:GetChildren())) |
08 | if player.Character and player.Character.HumanoidRootPart then |
09 | player.Character:MoveTo(workspace.Teleports.LobbyBase.base.Position) |
10 | end |
11 | -- Give tools |
12 | for i,v in pairs (game.ServerStorage.StamperTools:GetChildren()) do |
13 | tool = v:Clone() |
14 | tool.Parent = player.Backpack |
15 | end |