Issue with ChatService module of default game script "ChatServiceRunner" breaking during map regeneration

  1. What do you want to achieve? Keep it simple and clear!
    I want to regenerate a map and scripts in a game I’m working on flawlessly without causing any scripts to break.
  2. What is the issue? Include screenshots / videos if possible!
    An error occurs with the “ChatService” ModuleScript of the default game script “ChatServiceRunner”:
    Screenshot of where the error occurs: image
    My code that does this is housed in a single script:
See 'Regen' Script
for i,v in pairs(game.ReplicatedStorage:GetChildren()) do --Reset BoolValues & StringValues in ReplicatedStorage
	if v.ClassName ~= "StringValue" and v.ClassName ~= "Folder" and v.ClassName ~= "IntValue" and v.ClassName ~= "RemoteEvent" and v.ClassName ~= "ScreenGui" then
		v.Value = false
	elseif v.ClassName ~= "Folder" and v.ClassName ~= "Folder" and v.ClassName ~= "IntValue" and v.ClassName ~= "RemoteEvent" and v.ClassName ~= "ScreenGui" then
		v.Value = ""
	end
end
for i,v in pairs(game.Workspace:GetChildren()) do --Destroy everything in Workspace except for an essential model, camera, and Terrain.
	if v.ClassName ~= "Camera" and v.ClassName ~= "Terrain" and v.Name ~= "WaitingBox" then
		v:Destroy()
	end
end
for i,v in pairs(game.ServerStorage.MapClone:GetChildren()) do --Replace the destroyed items in Workspace with a copy of the map from a folder in ServerStorage
	local cloned = v:Clone()
	cloned.Parent = game.Workspace
end
for i,v in pairs(game.ServerScriptService:GetChildren()) do -- Destroy the existing scripts
	if v.Name ~= "Regen" and v.Name ~= "Adonis_Loader" and v.Name ~= "MainModule" and v.Name ~= "ChatServiceRunner" then
		v:Destroy()
	end
end
for i,v in pairs(game.ServerStorage.ScriptClone:GetChildren()) do -- This is a folder of cloned scripts, including the script this code is running in(Also replacing the scripts in ServerScriptService that were destroyed).
	local cloned = v:Clone()
	cloned.Parent = game.ServerScriptService
end

game.ReplicatedStorage.ButtonValue.Value = 6 --This is just a value I'm setting to 6
game.ServerScriptService.StartupTrigger.Disabled = false
game.ServerScriptService.Script.Disabled = false
game.ServerScriptService.Shutdown_Button.Disabled = false --Enable essential scripts necessary for certain functions of the game to work upon reloading the map and scripts.
for i,v in pairs(game.Players:GetChildren()) do -- Respawn all players(They are teleported into the "WaitingBox" model while this script is running).
	if v.Character then
		v:LoadCharacter()
	end
end
script:Destroy()
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    At first, I simply tried destroying the ChatServiceRunner script and replacing it in a clone, but it still errored. I could not figure out where the object defined as “Speaker” in the ChatService was, otherwise I would have made sure to delete that, then reload scripts.

Most importantly, I want to know how I can stop the ChatService module from breaking, so the in-game chat still works. If there is already a solution in another thread, please point me to there as I could not find such a solution myself when I searched.

So after a good bit of research, I figured out how to remove the Speaker object “Server”. Just needed to look up the article reference for the chat system.