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.
function doSpecialRound(buildTime, voteTime, intermissionTime) throw("notification","This round will be different!") wait(11) throw("notification","This round you will have to guess what the player is building") setStatus("Choosing builder...") wait(3) player = get_Child(game.Players,math.random(0,#game.Players:GetChildren())) if player.Character and player.Character.HumanoidRootPart then player.Character:MoveTo(workspace.Teleports.LobbyBase.base.Position) end -- Give tools for i,v in pairs(game.ServerStorage.StamperTools:GetChildren()) do tool = v:Clone() tool.Parent = player.Backpack end ncs = script.Resources.NoChatScript:Clone() ncs.Parent = player.Backpack ncs.Disabled = false workspace.MakeChat:FireAllClients("The bonus round has started! Chat what you think the builder is making!") i = 90 category = tostring(cat[ch]) for i,v in pairs(game.Players:GetChildren()) do v.PlayerGui.main.Frame.Category.Text = "Mystery" end player.PlayerGui.main.Frame.Category.Text = category -- Chat hook setStatus("Mystery round...") for i,v in pairs(game.Players:GetChildren()) do pcall(function() v.Chatted:connect(function(msg) if string.lower(msg) == string.lower(category) then throw("msg",v.Name .. " has guessed the theme!") workspace.MakeChat("The theme was " .. category) game.PointsService:AwardPoints(v.UserId,100) v.leaderstats.Wins.Value = v.leaderstats.Wins.Value+1 for i,v in pairs(game.Players:GetChildren()) do pcall(function() v.Chatted:disconnect() -- Deprecated, but options are limited end) end end end) end) end while i > -1 do for i,v in pairs(game.Players:GetChildren()) do pcall(function() v.PlayerGui.main.Frame.Time = i i=i-1 wait(1) end) end end end
EDIT (1):
local get_Child=function(obj,index) return obj:children()[tonumber(index)] 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:
function doSpecialRound(buildTime, voteTime, intermissionTime) throw("notification","This round will be different!") wait(11) throw("notification","This round you will have to guess what the player is building") setStatus("Choosing builder...") wait(3) player = get_Child(game.Players,math.random(0,#game.Players:GetChildren())) if player.Character and player.Character.HumanoidRootPart then player.Character:MoveTo(workspace.Teleports.LobbyBase.base.Position) end -- Give tools for i,v in pairs(game.ServerStorage.StamperTools:GetChildren()) do tool = v:Clone() tool.Parent = player.Backpack end ncs = script.Resources.NoChatScript:Clone() ncs.Parent = player.Backpack ncs.Disabled = false workspace.MakeChat:FireAllClients("The bonus round has started! Chat what you think the builder is making!") timer = 90 category = tostring(cat[ch]) for i,v in pairs(game.Players:GetChildren()) do v.PlayerGui.main.Frame.Category.Text = "Mystery" end player.PlayerGui.main.Frame.Category.Text = category -- Chat hook setStatus("Mystery round...") for i,v in pairs(game.Players:GetChildren()) do pcall(function() v.Chatted:connect(function(msg) if string.lower(msg) == string.lower(category) then throw("msg",v.Name .. " has guessed the theme!") workspace.MakeChat("The theme was " .. category) game.PointsService:AwardPoints(v.UserId,100) v.leaderstats.Wins.Value = v.leaderstats.Wins.Value+1 for i,v in pairs(game.Players:GetChildren()) do pcall(function() v.Chatted:disconnect() -- Deprecated, but options are limited end) end end end) end) end while timer > -1 do for _,v in pairs(game.Players:GetChildren()) do pcall(function() v.PlayerGui.main.Frame.Time = timer timer=timer-1 wait(1) end) end end end