0% found this document useful (0 votes)
5 views5 pages

Trivia Game Script Overview

patched

Uploaded by

wyoruu29k
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Trivia Game Script Overview

patched

Uploaded by

wyoruu29k
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

-- Trivia Questions and Answers

local triviaQuestions = {
{question = "What is the capital of France?", answers = {"paris", "Paris"},
points = [Link](5, 15)},
{question = "Which continent is Egypt located in?", answers = {"africa",
"Africa"}, points = [Link](5, 15)},
{question = "What is the largest country in the world by area?", answers =
{"russia", "Russia"}, points = [Link](5, 15)},
{question = "Which ocean is the smallest?", answers = {"arctic ocean", "Arctic
Ocean"}, points = [Link](5, 15)},
{question = "Which country has the longest coastline?", answers = {"canada",
"Canada"}, points = [Link](5, 15)},
{question = "What is the largest desert in the world?", answers = {"sahara",
"Sahara"}, points = [Link](5, 15)},
{question = "Which river is the longest in the world?", answers = {"nile",
"Nile"}, points = [Link](5, 15)},
{question = "What is the capital city of Australia?", answers = {"canberra",
"Canberra"}, points = [Link](5, 15)},
{question = "Which mountain range separates Europe and Asia?", answers = {"ural
mountains", "Ural Mountains"}, points = [Link](5, 15)},
{question = "Which city is known as the 'City of Canals'?", answers =
{"venice", "Venice"}, points = [Link](5, 15)},
{question = "What is the smallest country in Europe by area?", answers =
{"monaco", "Monaco"}, points = [Link](5, 15)},
{question = "Which continent has the most countries?", answers = {"africa",
"Africa"}, points = [Link](5, 15)},
{question = "Which country is home to the Great Wall?", answers = {"china",
"China"}, points = [Link](5, 15)},
{question = "What is the capital of Canada?", answers = {"ottawa", "Ottawa"},
points = [Link](5, 15)},
{question = "Which country is known as the 'Land of the Midnight Sun'?",
answers = {"norway", "Norway"}, points = [Link](5, 15)},
{question = "Which U.S. state is the smallest by area?", answers = {"rhode
island", "Rhode Island"}, points = [Link](5, 15)},
{question = "What is the largest island in the world?", answers = {"greenland",
"Greenland"}, points = [Link](5, 15)},
{question = "Which African country has a coastline on both the Atlantic and
Indian Oceans?", answers = {"south africa", "South Africa"}, points =
[Link](5, 15)},
{question = "Which country is known as the 'Emerald Isle'?", answers =
{"ireland", "Ireland"}, points = [Link](5, 15)},
{question = "Which city is known as the 'Eternal City'?", answers = {"rome",
"Rome"}, points = [Link](5, 15)},
{question = "What is the capital city of Japan?", answers = {"tokyo", "Tokyo"},
points = [Link](5, 15)},
{question = "Which desert is located in northern Chile?", answers = {"atacama",
"Atacama"}, points = [Link](5, 15)},
{question = "Which country has the largest population?", answers = {"china",
"China"}, points = [Link](5, 15)},
{question = "What is the largest lake in Africa?", answers = {"lake victoria",
"Lake Victoria"}, points = [Link](5, 15)},
{question = "Which continent is known for its unique wildlife including
kangaroos and koalas?", answers = {"australia", "Australia"}, points =
[Link](5, 15)},
{question = "Which river flows through Egypt?", answers = {"nile", "Nile"},
points = [Link](5, 15)},
{question = "Which country is known as the 'Land of Fire and Ice'?", answers =
{"iceland", "Iceland"}, points = [Link](5, 15)},
{question = "Which mountain is known as the highest peak in the world?",
answers = {"everest", "Everest"}, points = [Link](5, 15)},
{question = "Which island nation is located southeast of India?", answers =
{"sri lanka", "Sri Lanka"}, points = [Link](5, 15)},
{question = "What is the capital of Brazil?", answers = {"brasilia",
"Brasilia"}, points = [Link](5, 15)},
{question = "Which city is known as the 'City of Angels'?", answers = {"los
angeles", "Los Angeles"}, points = [Link](5, 15)},
{question = "What is the largest volcano in the world?", answers = {"mauna
loa", "Mauna Loa"}, points = [Link](5, 15)},
{question = "Which country has the most number of islands?", answers =
{"sweden", "Sweden"}, points = [Link](5, 15)},
{question = "Which European city is known as the 'City of Lights'?", answers =
{"paris", "Paris"}, points = [Link](5, 15)},
{question = "Which U.S. state is known for its geysers and hot springs?",
answers = {"wyoming", "Wyoming"}, points = [Link](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


[Link](sortedPlayers, {Id = playerId, Score = score})
end
[Link](sortedPlayers, function(a, b) return [Link] > [Link] end)

for i, player in ipairs(sortedPlayers) do


local playerInstance = Players:GetPlayerByUserId([Link])
if playerInstance then
local medal = ""
if i == 1 then
medal = "🥇"
elseif i == 2 then
medal = "🥈"
elseif i == 3 then
medal = "🥉"
end
leaderboardText = leaderboardText .. medal .. " - " ..
[Link] .. ": " .. [Link] .. " 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 .. ": " ..
[Link], 8184068358)
questionAnsweredBy = nil
end

local function onPlayerChatted(player, message)


if triviaEnded then return end

if bannedPlayers[[Link]] then
return
end

local currentQuestion = triviaQuestions[currentQuestionIndex]

if questionAnsweredBy then
return
end

local cleanedMessage = [Link](message):match("^%s*(.-)%s*$")


if [Link](allowedPlayerIds, [Link]) then
if cleanedMessage:match("^!skip") then
currentQuestionIndex = currentQuestionIndex + 1
displayQuestion()
return
elseif cleanedMessage:match("^!answerall") then
for _, question in ipairs(triviaQuestions) do
playerScores[[Link]] = (playerScores[[Link]] or
0) + [Link]
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([Link]) do


if cleanedMessage == [Link](answer) then
if not questionAnsweredBy then
questionAnsweredBy = [Link]

local pointsEarned = [Link]([Link] + 0.5)


playerScores[[Link]] = (playerScores[[Link]] or
0) + pointsEarned

updateBoothText([Link] .. " has the correct answer!


Points: " .. pointsEarned, 505845272)
wait(3)

currentQuestionIndex = currentQuestionIndex + 1
displayQuestion()
end
break
end
end
end

[Link]:Connect(function(player)
[Link]:Connect(function(message)
onPlayerChatted(player, message)
end)
end)

for _, player in pairs(Players:GetPlayers()) do


[Link]:Connect(function(message)
onPlayerChatted(player, message)
end)
end

displayQuestion()
end

startTrivia()

You might also like