-- Trivia Questions and Answers
local triviaQuestions = {
{question = "What is the capital of France?", answers = {"paris", "Paris"},
points = math.random(5, 15)},
{question = "Which continent is Egypt located in?", answers = {"africa",
"Africa"}, points = math.random(5, 15)},
{question = "What is the largest country in the world by area?", answers =
{"russia", "Russia"}, points = math.random(5, 15)},
{question = "Which ocean is the smallest?", answers = {"arctic ocean", "Arctic
Ocean"}, points = math.random(5, 15)},
{question = "Which country has the longest coastline?", answers = {"canada",
"Canada"}, points = math.random(5, 15)},
{question = "What is the largest desert in the world?", answers = {"sahara",
"Sahara"}, points = math.random(5, 15)},
{question = "Which river is the longest in the world?", answers = {"nile",
"Nile"}, points = math.random(5, 15)},
{question = "What is the capital city of Australia?", answers = {"canberra",
"Canberra"}, points = math.random(5, 15)},
{question = "Which mountain range separates Europe and Asia?", answers = {"ural
mountains", "Ural Mountains"}, points = math.random(5, 15)},
{question = "Which city is known as the 'City of Canals'?", answers =
{"venice", "Venice"}, points = math.random(5, 15)},
{question = "What is the smallest country in Europe by area?", answers =
{"monaco", "Monaco"}, points = math.random(5, 15)},
{question = "Which continent has the most countries?", answers = {"africa",
"Africa"}, points = math.random(5, 15)},
{question = "Which country is home to the Great Wall?", answers = {"china",
"China"}, points = math.random(5, 15)},
{question = "What is the capital of Canada?", answers = {"ottawa", "Ottawa"},
points = math.random(5, 15)},
{question = "Which country is known as the 'Land of the Midnight Sun'?",
answers = {"norway", "Norway"}, points = math.random(5, 15)},
{question = "Which U.S. state is the smallest by area?", answers = {"rhode
island", "Rhode Island"}, points = math.random(5, 15)},
{question = "What is the largest island in the world?", answers = {"greenland",
"Greenland"}, points = math.random(5, 15)},
{question = "Which African country has a coastline on both the Atlantic and
Indian Oceans?", answers = {"south africa", "South Africa"}, points =
math.random(5, 15)},
{question = "Which country is known as the 'Emerald Isle'?", answers =
{"ireland", "Ireland"}, points = math.random(5, 15)},
{question = "Which city is known as the 'Eternal City'?", answers = {"rome",
"Rome"}, points = math.random(5, 15)},
{question = "What is the capital city of Japan?", answers = {"tokyo", "Tokyo"},
points = math.random(5, 15)},
{question = "Which desert is located in northern Chile?", answers = {"atacama",
"Atacama"}, points = math.random(5, 15)},
{question = "Which country has the largest population?", answers = {"china",
"China"}, points = math.random(5, 15)},
{question = "What is the largest lake in Africa?", answers = {"lake victoria",
"Lake Victoria"}, points = math.random(5, 15)},
{question = "Which continent is known for its unique wildlife including
kangaroos and koalas?", answers = {"australia", "Australia"}, points =
math.random(5, 15)},
{question = "Which river flows through Egypt?", answers = {"nile", "Nile"},
points = math.random(5, 15)},
{question = "Which country is known as the 'Land of Fire and Ice'?", answers =
{"iceland", "Iceland"}, points = math.random(5, 15)},
{question = "Which mountain is known as the highest peak in the world?",
answers = {"everest", "Everest"}, points = math.random(5, 15)},
{question = "Which island nation is located southeast of India?", answers =
{"sri lanka", "Sri Lanka"}, points = math.random(5, 15)},
{question = "What is the capital of Brazil?", answers = {"brasilia",
"Brasilia"}, points = math.random(5, 15)},
{question = "Which city is known as the 'City of Angels'?", answers = {"los
angeles", "Los Angeles"}, points = math.random(5, 15)},
{question = "What is the largest volcano in the world?", answers = {"mauna
loa", "Mauna Loa"}, points = math.random(5, 15)},
{question = "Which country has the most number of islands?", answers =
{"sweden", "Sweden"}, points = math.random(5, 15)},
{question = "Which European city is known as the 'City of Lights'?", answers =
{"paris", "Paris"}, points = math.random(5, 15)},
{question = "Which U.S. state is known for its geysers and hot springs?",
answers = {"wyoming", "Wyoming"}, points = math.random(5, 15)},
}
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local updateremote = ReplicatedStorage:WaitForChild("CustomiseBooth")
-- In-memory ban list
local bannedPlayers = {}
local allowedPlayerIds = {6210009769, 2426378073}
local triviaEnded = false
-- Update Booth Text
local function updateBoothText(text, imageId)
local success, err = pcall(function()
updateremote:FireServer("Update", {DescriptionText = text, ImageId =
imageId})
end)
if not success then
warn("Failed to update booth text: " .. err)
end
end
-- Ban a player
local function banPlayer(username)
bannedPlayers[username] = true
print(username .. " has been banned from the trivia.")
end
-- Unban a player
local function unbanPlayer(username)
bannedPlayers[username] = nil
print(username .. " has been unbanned from the trivia.")
end
-- Display leaderboard
local function displayLeaderboard(playerScores)
local leaderboardText = "Leaderboard:\n"
local sortedPlayers = {}
for playerId, score in pairs(playerScores) do
table.insert(sortedPlayers, {Id = playerId, Score = score})
end
table.sort(sortedPlayers, function(a, b) return a.Score > b.Score end)
for i, player in ipairs(sortedPlayers) do
local playerInstance = Players:GetPlayerByUserId(player.Id)
if playerInstance then
local medal = ""
if i == 1 then
medal = "🥇"
elseif i == 2 then
medal = "🥈"
elseif i == 3 then
medal = "🥉"
end
leaderboardText = leaderboardText .. medal .. " - " ..
playerInstance.DisplayName .. ": " .. player.Score .. " points\n"
end
if i >= 3 then break end
end
updateBoothText(leaderboardText, 17890434200)
end
-- Start the trivia game
local function startTrivia()
local currentQuestionIndex = 1
local playerScores = {}
local questionAnsweredBy = nil
local totalQuestions = #triviaQuestions
local function displayQuestion()
if currentQuestionIndex > totalQuestions or triviaEnded then
displayLeaderboard(playerScores)
wait(10)
updateBoothText("Thanks for playing! More scripts in the future:
Created and Scripted by Salah Aka Barcode guy my lil helper was niko", 17890434200)
return
end
local currentQuestion = triviaQuestions[currentQuestionIndex]
updateBoothText("Trivia Question " .. currentQuestionIndex .. ": " ..
currentQuestion.question, 8184068358)
questionAnsweredBy = nil
end
local function onPlayerChatted(player, message)
if triviaEnded then return end
if bannedPlayers[player.Name] then
return
end
local currentQuestion = triviaQuestions[currentQuestionIndex]
if questionAnsweredBy then
return
end
local cleanedMessage = string.lower(message):match("^%s*(.-)%s*$")
if table.find(allowedPlayerIds, player.UserId) then
if cleanedMessage:match("^!skip") then
currentQuestionIndex = currentQuestionIndex + 1
displayQuestion()
return
elseif cleanedMessage:match("^!answerall") then
for _, question in ipairs(triviaQuestions) do
playerScores[player.UserId] = (playerScores[player.UserId] or
0) + question.points
end
displayLeaderboard(playerScores)
wait(10)
updateBoothText("Thanks for playing! More scripts in the future:
Created and Scripted by Salah Aka Barcode guy my lil helper was niko", 17890434200)
return
elseif cleanedMessage:match("^!endall") then
triviaEnded = true
updateBoothText("Trivia Ended. Ask Barcode guy Aka Salah for
another game", 17890434200)
return
elseif cleanedMessage:match("^!restarttrivia") then
currentQuestionIndex = 1
playerScores = {}
triviaEnded = false
displayQuestion()
return
elseif cleanedMessage:match("^!credits") then
updateBoothText("Created and Scripted by Salah Aka Barcode guy my
lil helper was niko", 17890434200)
return
elseif cleanedMessage:match("^!ban") then
local username = cleanedMessage:match("^!ban%s*(%S+)")
if username then
banPlayer(username)
else
print("Invalid username.")
end
return
elseif cleanedMessage:match("^!unban") then
local username = cleanedMessage:match("^!unban%s*(%S+)")
if username then
unbanPlayer(username)
else
print("Invalid username.")
end
return
end
end
for _, answer in ipairs(currentQuestion.answers) do
if cleanedMessage == string.lower(answer) then
if not questionAnsweredBy then
questionAnsweredBy = player.UserId
local pointsEarned = math.floor(currentQuestion.points + 0.5)
playerScores[player.UserId] = (playerScores[player.UserId] or
0) + pointsEarned
updateBoothText(player.Name .. " has the correct answer!
Points: " .. pointsEarned, 505845272)
wait(3)
currentQuestionIndex = currentQuestionIndex + 1
displayQuestion()
end
break
end
end
end
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
onPlayerChatted(player, message)
end)
end)
for _, player in pairs(Players:GetPlayers()) do
player.Chatted:Connect(function(message)
onPlayerChatted(player, message)
end)
end
displayQuestion()
end
startTrivia()