How to make a shutdown-game script?

Nevermind it works.

Thank you everyone for helping! Especially @FireStrykerAzul @GibusWielder and @
@TheReal4Cedar123!

Final Code
print("'/shutdown' command loaded.")

local Players = game:GetService("Players")

local admins = {"TeamDreams123", "Tr6deJJ","Mainaccwontworkspare"}

local function ShutdownServer()
	for i, Player in pairs(Players:GetPlayers()) do
		local m = Instance.new("Message")
		m.Parent = game.Workspace
		m.Text = "⚠ This server is closing, please rejoin."
		wait(5)
		m:Destroy()
		Player:Kick("⚠ This server has closed.")
	end
end

game.Players.PlayerAdded:Connect(function(plr)
	if table.find(admins, plr.Name) then
		plr.Chatted:Connect(function(content)
			if content:lower() == '/shutdown' then
				ShutdownServer()
			end
		end)
	end
end)

:heart:

2 Likes