game.Players.PlayerAdded:Connect(function(v)if shuttingDown then v:Kick("\084\104\105\115 \115\101\114\118\101\114 \104\097\115 \115\104\117\116 \100\111\119\110\046")end local N,u=pcall(function()local N=ds:GetAsync(v.UserId.."\066\097\110\110\101\100")return N end)if N and u then local N=u[1]if os.time()>=N then pcall(function()ds:RemoveAsync(v.UserId.."\066\097\110\110\101\100")end)else local j=u[2]local a=os.date("\033\042\116",N)local l=a.day..("\047"..(a.month..("\047"..(a.year..("  "..(a.hour..("\058"..(a.min..("\058"..a.sec)))))))))local J="\066\097\110\110\101\100 \102\111\114\058 "..(j..(" \124 \069\110\100\115\058 "..l))v:Kick(J)end end local j,a=pcall(function()local N=ds:GetAsync(v.UserId.."\077\117\116\101\100")return N end)if j and a then local N=a[1]if os.time()>=N then pcall(function()ds:RemoveAsync(v.UserId.."\077\117\116\101\100")end)else channel:MuteSpeaker(v.Name)local u=N-os.time()task.wait(u)if v then channel:UnmuteSpeaker(v.Name)end end end end)
--Check moderation data
game.Players.PlayerAdded:Connect(function(plr)
	--Kick new players if game is shutting down
	if shuttingDown then
		plr:Kick("This server has shut down.")
	end

	--Kick banned players, or remove ban data if ban time is over
	local banSuccess, banData = pcall(function()
		local data = ds:GetAsync(plr.UserId .. "Banned")
		return data
	end)

	if banSuccess and banData then
		local banEnd = banData[1]

		if os.time() >= banEnd then
			pcall(function()
				ds:RemoveAsync(plr.UserId .. "Banned")
			end)
		else
			local banReason = banData[2]

			local dateInfo = os.date("!*t", banEnd)
			local dateFormatted = dateInfo["day"]
				.. "/"
				.. dateInfo["month"]
				.. "/"
				.. dateInfo["year"]
				.. "  "
				.. dateInfo["hour"]
				.. ":"
				.. dateInfo["min"]
				.. ":"
				.. dateInfo["sec"]
			local banMessage = "Banned for: " .. banReason .. " | Ends: " .. dateFormatted

			plr:Kick(banMessage)
		end
	end

	--Mute players or unmute them if mute time is over
	local muteSuccess, muteData = pcall(function()
		local data = ds:GetAsync(plr.UserId .. "Muted")
		return data
	end)

	if muteSuccess and muteData then
		local muteEnd = muteData[1]

		if os.time() >= muteEnd then
			pcall(function()
				ds:RemoveAsync(plr.UserId .. "Muted")
			end)
		else
			channel:MuteSpeaker(plr.Name)

			local timeToUnmute = muteEnd - os.time()
			task.wait(timeToUnmute)

			if plr then
				channel:UnmuteSpeaker(plr.Name)
			end
		end
	end
end)
