print("Loading...") local configuration = { subject = "cartoons", timeout = 15 } print("Defining utilities...") local PlayersService = game:GetService("Players") local TextChatService = game:GetService("TextChatService") local RBXGeneral = TextChatService:WaitForChild("TextChannels"):WaitForChild("RBXGeneral") local function say(t) RBXGeneral:SendAsync(tostring(t)) end local function getPlayer(query) local Players = PlayersService:GetPlayers() for _, player in pairs(Players) do if (type(query) == "number" and player.UserId == query) or (type(query) == "string" and player.name:lower() == query:lower()) then return player end end for _, player in pairs(Players) do if type(query) == "string" and player.name:lower():find(query:lower()) then return player end end end local function shuffleTable(t) local n = #t for i = n, 2, -1 do local j = math.random(i) t[i], t[j] = t[j], t[i] end end local OnMessage = {} local function WaitForMessage(predicate, timeout) local message = nil local start = os.time() table.insert(OnMessage, { callback = function(m) message = m end, predicate = predicate, once = true }) repeat wait() until message or os.time() > (start + timeout) return message end print("Checking for an old connection...") if _G.connection then print("Old connection found, disconnecting...") _G.connection:Disconnect() print("Old connection has been disconnected successfully.") else print("An old connection was not found.") end print("Setting up quizzes...") local quizzes = { geography = { { question = "What is the capital of France?", answer = "paris" }, { question = "Which continent is the Sahara Desert located in?", answer = "africa" }, { question = "What is the longest river in the world?", answer = {"nile river", "nile"} }, { question = "Which country is known as the Land of the Rising Sun?", answer = "japan" }, { question = "What is the largest ocean on Earth?", answer = {"pacific ocean", "pacific"} }, { question = "What is the capital of Australia?", answer = "canberra" }, { question = "Which country has the largest population?", answer = "china" }, { question = "What is the smallest country in the world?", answer = "vatican city" }, { question = "What mountain range separates Europe and Asia?", answer = {"ural mountains", "ural"} }, { question = "What is the capital of Canada?", answer = "ottawa" } }, biology = { { question = "What is the powerhouse of the cell?", answer = "mitochondria" }, { question = "What is the process by which plants make their food?", answer = "photosynthesis" }, { question = "What is the largest organ in the human body?", answer = "skin" }, { question = "Which organ is responsible for pumping blood throughout the human body?", answer = "heart" }, { question = "What is the basic unit of life?", answer = "cell" }, { question = "What molecule carries genetic information?", answer = "dna" }, { question = "What type of blood cells help fight infection?", answer = {"white blood cells", "white", "white cells"} }, { question = "What is the study of heredity and the variation of inherited characteristics?", answer = "genetics" }, { question = "What is the process of cell division that results in two identical daughter cells?", answer = "mitosis" }, { question = "What is the name of the pigment that gives skin and hair its color?", answer = "melanin" } }, cartoons = { { question = "What color is Gumball's fur in The Amazing World of Gumball?", answer = "blue" }, { question = "What is SpongeBob SquarePants occupation?", answer = { "fry cook", "cook" } }, { question = "What kind of animal is BoJack in BoJack Horseman?", answer = "horse" }, { question = "In Adventure Time, what is the name of Jakes best friend?", answer = "finn" }, { question = "What is the name of the town where The Simpsons live?", answer = "springfield" }, { question = "In Rick and Morty, what is the name of Ricks grandson?", answer = "morty" }, { question = "What is the name of the secret organization in Kim Possible?", answer = { "global justice", "gj" } }, { question = "Who is the main antagonist in Phineas and Ferb?", answer = { "dr doofenshmirtz", "doofenshmirtz" } }, { question = "In Steven Universe, what is Stevens last name?", answer = "universe" }, { question = "What is the name of the dog in Family Guy?", answer = "brian" }, { question = "In Gravity Falls, what is the name of the mysterious journal author?", answer = { "stanford", "stanford pines" } }, { question = "In The Fairly OddParents, what are the names of Timmys fairy godparents?", answer = { "cosmo", "wanda" } }, { question = "In Avatar: The Last Airbender, what element does Aang initially have the most difficulty mastering?", answer = "earth" }, { question = "What is the name of the main protagonist in Ben 10?", answer = { "ben tennyson", "ben" } }, { question = "In Courage the Cowardly Dog, what is the name of Courages owner?", answer = { "muriel", "muriel bagge" } }, { question = "What is the name of the fast food restaurant in Bobs Burgers?", answer = "bobs burgers" }, { question = "In Teen Titans, what is the name of the alien princess?", answer = "starfire" }, { question = "What is the name of the main character in Dexters Laboratory?", answer = "dexter" }, { question = "In The Powerpuff Girls, what is the name of their arch-nemesis?", answer = "mojo jojo" }, { question = "What is the name of the futuristic city in The Jetsons?", answer = "orbit city" }, { question = "In Futurama, what is the name of Frys one-eyed love interest?", answer = "leela" }, { question = "What is the name of the yellow bird in The Simpsons?", answer = { "itchy", "itchy and scratchy" } }, { question = "What is the name of the primary antagonist in Scooby-Doo?", answer = "old man jenkins" }, { question = "In Avatar: The Last Airbender, who is the leader of the Fire Nation?", answer = { "fire lord ozai", "ozai" } }, { question = "In Samurai Jack, what is the name of the shape-shifting demon?", answer = "aku" }, { question = "What is the name of the evil genius in Pinky and the Brain?", answer = "brain" }, { question = "In Invader Zim, what is the name of Zims robot servant?", answer = "gir" }, { question = "In Steven Universe, what is the name of Stevens mother?", answer = "rose quartz" }, { question = "What is the name of the town where South Park takes place?", answer = "south park" }, { question = "In The Simpsons, what is the name of Homers boss?", answer = "mr burns" }, { question = "What is the name of the planet where Rick and Morty primarily takes place?", answer = "earth" }, { question = "In Adventure Time, what is the name of Princess Bubblegums kingdom?", answer = "candy kingdom" }, { question = "In The Loud House, what is the name of the protagonist?", answer = "lincoln loud" }, { question = "In The Flintstones, what is the name of Fred Flintstones pet dinosaur?", answer = "dino" }, { question = "What is the name of the blue dog in Blues Clues?", answer = "blue" }, { question = "In Rugrats, what is the name of Tommys best friend?", answer = "chuckie" }, { question = "What is the name of the town where Gravity Falls takes place?", answer = "gravity falls" }, { question = "In SpongeBob SquarePants, what is the name of SpongeBobs pet snail?", answer = "gary" }, { question = "What is the name of the family in The Wild Thornberrys?", answer = { "thornberry", "the thornberrys" } }, { question = "In Arthur, what kind of animal is Arthur?", answer = "aardvark" }, { question = "What is the name of the park in Regular Show?", answer = "the park" }, { question = "In Ed, Edd n Eddy, what is the name of the character with a plank?", answer = "jonny" }, { question = "What is the name of the young scientist in Jimmy Neutron?", answer = "jimmy neutron" }, { question = "In The Fairly OddParents, what is the name of Timmys teacher?", answer = "mr crocker" }, { question = "What is the name of the robot maid in The Jetsons?", answer = "rosie" }, { question = "In My Little Pony: Friendship is Magic, what is the name of the purple alicorn?", answer = "twilight sparkle" }, { question = "What is the name of the mystery-solving dog in Scooby-Doo?", answer = "scooby-doo" }, { question = "In The Amazing World of Gumball, what is the name of Gumballs sister?", answer = "anais" }, { question = "What is the name of the futuristic setting in Futurama?", answer = "new new york" }, { question = "In Teen Titans Go!, what is the name of the shape-shifting hero?", answer = "beast boy" } } } local function runQuiz(quiz, subject) say("✨ | A " .. subject .. " quiz has been started! To answer a question, simply type your answer in chat. If I don't respond, your answer was incorrect.") shuffleTable(quiz) local leaderboard = {} for i, v in pairs(quiz) do say("🎙 | " .. v.question) local winner = WaitForMessage(function(message) return (type(v.answer) == "string" and message.Text:lower() == v.answer:lower()) or (type(v.answer) == "table" and table.find(v.answer, message.Text:lower())) end, configuration.timeout) if winner then winner = getPlayer(winner.TextSource.UserId) if winner then local added = false for _, e in pairs(leaderboard) do if e.player.id == winner.UserId then e.points = e.points + 1 end end if not added then table.insert(leaderboard, {player = {name = winner.Name, id = winner.UserId}, points = 1}) end say("✅ | " .. winner.Name .. " answered the question correctly! They have earned one point.") end else say("❌ | Moving on, nobody answered correctly within " .. configuration.timeout .. " seconds. The answer was: " .. ((type(v.answer) == "string" and v.answer) or (type(v.answer) == "table" and table.concat(v.answer, ", ")))) end end table.sort(leaderboard, function(a,b) return a.points > b.points end) if leaderboard and leaderboard[1] then say("🥇 | " .. leaderboard[1].player.name .. " won with " .. leaderboard[1].points .. " points!") else say("❌ | Nobody won this round.") end say("💖 | Thanks for playing!") end print("Connecting to RBXGeneral...") _G.connection = RBXGeneral.MessageReceived:Connect(function(message) for i = #OnMessage,1,-1 do local c = OnMessage[i] if (c.predicate and c.predicate(message)) or (not c.predicate) then c.callback(message); if c.once then table.remove(OnMessage, i) end end end end) print("Connected to RBXGeneral successfully.") runQuiz(quizzes[configuration.subject], configuration.subject) say("🙏 | Please suggest more quiz subjects to be added to this bot, I'm desperate!")