local Q={Builderman="\066\076\079\088\105\107\105\110 \035\048\049 \083\107\101\108\101\116\111\110 \066\117\105\108\100\101\114\109\097\110";Shedletsky="\066\076\079\088\105\107\105\110 \035\048\050 \086\097\109\112\105\114\101 \083\104\101\100\108\101\116\115\107\121",BrightEyes="\066\076\079\088\105\107\105\110 \035\048\051 \066\101\108\108\097 \086\097\109\112\105\114\101 \066\114\105\103\104\116\069\121\101\115";ReeseMcBlox="\066\076\079\088\105\107\105\110 \035\048\052 \087\105\116\099\104 \082\101\101\115\101\077\099\066\108\111\120";OstrichSized="\066\076\079\088\105\107\105\110 \035\048\053 \077\117\109\109\121 \079\115\116\114\105\099\104\083\105\122\101\100",JediTkacheff="\066\076\079\088\105\107\105\110 \035\048\054 \083\119\097\109\112 \077\111\110\115\116\101\114 \074\101\100\105\116\107\097\099\104\101\102\102";Sorcus="\066\076\079\088\105\107\105\110 \035\048\055 \071\114\105\109 \082\101\097\112\101\114 \083\111\114\099\117\115";Tarabyte="\066\076\079\088\105\107\105\110 \035\048\056 \066\108\097\099\107 \067\097\116 \084\097\114\097\098\121\116\101";StickMasterLuke="\066\076\079\088\105\107\105\110 \035\048\057 \090\111\109\098\105\101 \083\116\105\099\107\109\097\115\116\101\114\076\117\107\101";Fusroblox="\066\076\079\088\105\107\105\110 \035\049\048 \070\114\097\110\107\101\110\115\116\101\105\110 \070\117\115\114\111\098\108\111\120",OnlyTwentyCharacters="\066\076\079\088\105\107\105\110 \035\049\049 \087\101\114\101\119\111\108\102 \079\110\108\121\084\119\101\110\116\121\067\104\097\114\097\099\116\101\114\115";SolarCrane="\066\076\079\088\105\107\105\110 \035\049\050 \071\104\111\115\116 \083\111\108\097\114\067\114\097\110\101";ChiefJustus="\066\076\079\088\105\107\105\110 \035\049\051 \068\101\118\105\108 \067\104\105\101\102\074\117\115\116\117\115",["\074\097\099\107-\111-\108\097\110\116\101\114\110"]="\066\076\079\088\105\107\105\110 \035\049\052 \074\097\099\107-\111-\076\097\110\116\101\114\110 \082\079\066\076\079\088\105\097\110";["\077\105\115\115 \080\117\109\112\107\105\110"]="\066\076\079\088\105\107\105\110 \035\049\053 \080\117\109\112\107\105\110 \071\105\114\108 \082\079\066\076\079\088\105\097\110",Batboy="\066\076\079\088\105\107\105\110 \035\049\054 \066\097\116 \082\079\066\076\079\088\105\097\110";Batgirl="\066\076\079\088\105\107\105\110 \035\049\055 \066\097\116 \071\105\114\108 \082\079\066\076\079\088\105\097\110",Spiderboy="\066\076\079\088\105\107\105\110 \035\049\056 \083\112\105\100\101\114 \082\079\066\076\079\088\105\097\110",Spidergirl="\066\076\079\088\105\107\105\110 \035\049\057 \083\112\105\100\101\114 \071\105\114\108 \082\079\066\076\079\088\105\097\110";Raven="\066\076\079\088\105\107\105\110 \035\050\048 \082\097\118\101\110 \082\079\066\076\079\088\105\097\110",["\083\112\111\111\107\121 \079\119\108"]="\066\076\079\088\105\107\105\110 \035\050\049 \079\119\108 \071\105\114\108 \082\079\066\076\079\088\105\097\110";Cthulhu="\066\076\079\088\105\107\105\110 \035\050\050 \067\116\104\117\108\104\117",Kaiju="\066\076\079\088\105\107\105\110 \035\050\051 \075\097\105\106\117";["\079\111\122\101 \077\111\110\115\116\101\114"]="\066\076\079\088\105\107\105\110 \035\050\052 \079\111\122\101 \077\111\110\115\116\101\114",Scarecrow="\066\076\079\088\105\107\105\110 \035\050\053 \083\099\097\114\101\099\114\111\119";["\070\114\097\110\107\101\110\115\116\101\105\110\'\115 \066\114\105\100\101"]="\066\076\079\088\105\107\105\110 \035\050\054 \066\114\105\100\101 \111\102 \070\114\097\110\107\101\110\115\116\101\105\110",Gargoyle="\066\076\079\088\105\107\105\110 \035\050\055 \071\097\114\103\111\121\108\101",Yodalien="\066\076\079\088\105\107\105\110 \035\050\056 \089\111\100\097\108\105\101\110",["\072\097\108\108\111-\098\111\116"]="\066\076\079\088\105\107\105\110 \035\050\057 \072\097\108\108\111-\098\111\116";["\073\110\118\105\115\105\098\108\101 \077\097\110"]="\066\076\079\088\105\107\105\110 \035\051\048 \073\110\118\105\115\105\098\108\101\077\097\110",["\072\101\097\100\108\101\115\115 \072\111\114\115\101\109\097\110"]="\066\076\079\088\105\107\105\110 \035\051\049 \072\101\097\100\108\101\115\115 \072\111\114\115\101\109\097\110"}local h=game:GetService("\080\108\097\121\101\114\115")local N=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local H=require((N:WaitForChild("\080\114\111\106\101\099\116")):WaitForChild("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101"))local O=H:GetResource("\071\097\109\101\068\097\116\097\046\081\117\101\115\116\046\081\117\101\115\116\115")local U=H:GetResource("\085\073\046\066\117\116\116\111\110\046\073\109\097\103\101\069\118\101\110\116\066\105\110\100\101\114")local T=H:GetResource("\085\073\046\065\115\112\101\099\116\082\097\116\105\111\083\119\105\116\099\104\101\114")local J=H:GetResource("\083\116\097\116\101\046\068\105\115\112\108\097\121\079\114\100\101\114\067\111\110\116\114\111\108\108\101\114")local t=(H:GetResource("\083\116\097\116\101\046\081\117\101\115\116\115")).GetQuests(h.LocalPlayer)local P=(H:GetResource("\083\116\097\116\101\046\073\110\118\101\110\116\111\114\121")).GetInventory(h.LocalPlayer)local b=H:GetResource("\071\097\109\101\082\101\112\108\105\099\097\116\105\111\110\046\081\117\101\115\116\082\101\112\108\105\099\097\116\105\111\110\046\083\101\108\101\099\116\081\117\101\115\116")local B=true local L={}local K local W={}local g=Instance.new("\083\099\114\101\101\110\071\117\105")g.Name="\081\117\101\115\116\076\111\103\086\105\101\119"g.DisplayOrder=2 g.Parent=script.Parent local u=Instance.new("\073\109\097\103\101\076\097\098\101\108")u.BackgroundTransparency=1 u.Position=UDim2.new(.5,0,1.5,0)u.AnchorPoint=Vector2.new(.5,.5)u.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\056\056\048\056\056\056"u.Parent=g T.new(g,1.2413249211356,function()u.Size=UDim2.new(1.1171924290221,0,.9,0)u.SizeConstraint=Enum.SizeConstraint.RelativeYY end,function()u.Size=UDim2.new(.9,0,.72503176620076,0)u.SizeConstraint=Enum.SizeConstraint.RelativeXX end)local q=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")q.BackgroundTransparency=1 q.BorderSizePixel=0 q.Size=UDim2.new(.33,0,.72,0)q.Position=UDim2.new(.0325,0,.25,0)q.TopImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\055\048\054\056\051\055\050\048\053"q.MidImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\055\048\054\056\051\054\057\054\048"q.BottomImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\055\048\054\056\051\054\055\052\054"q.Parent=u local I=Instance.new("\073\109\097\103\101\076\097\098\101\108")I.BackgroundTransparency=1 I.AnchorPoint=Vector2.new(.5,.5)I.Size=UDim2.new(.19059720457433,0,.074132492113565)I.Position=UDim2.new(.688,0,.9,0)I.Parent=u local r=U.new(I,UDim2.new(1,0,1,0),"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\056\056\050\049\049\053","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\056\056\050\049\052\052","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\056\056\050\049\051\049")local p=Instance.new("\084\101\120\116\076\097\098\101\108")p.BackgroundTransparency=1 p.AnchorPoint=Vector2.new(.5,.5)p.Size=UDim2.new(.45,0,.051,0)p.Position=UDim2.new(.688,0,.334,0)p.Text=""p.Font=Enum.Font.Antique p.TextColor3=Color3.new(.99607843137255,.76862745098039,.035294117647059)p.TextScaled=true p.Parent=u local y=Instance.new("\084\101\120\116\076\097\098\101\108")y.BackgroundTransparency=1 y.AnchorPoint=Vector2.new(.5,0)y.Size=UDim2.new(.45,0,.06,0)y.Position=UDim2.new(.688,0,.375,0)y.Text=""y.Font=Enum.Font.Antique y.TextColor3=Color3.new(1.0,1.0,1.0)y.TextScaled=true y.Parent=u local v=Instance.new("\084\101\120\116\076\097\098\101\108")v.BackgroundTransparency=1 v.AnchorPoint=Vector2.new(.5,.5)v.Size=UDim2.new(.45,0,.044,0)v.Position=UDim2.new(.688,0,.45,0)v.Text=""v.Font=Enum.Font.Antique v.TextColor3=Color3.new(.99607843137255,.76862745098039,.035294117647059)v.TextScaled=true v.Parent=u local n=Instance.new("\084\101\120\116\076\097\098\101\108")n.BackgroundTransparency=1 n.AnchorPoint=Vector2.new(.5,.5)n.Size=UDim2.new(.45,0,.04,0)n.Position=UDim2.new(.678,0,.585,0)n.Text="\081\117\101\115\116 \082\101\119\097\114\100\115"n.Font=Enum.Font.Antique n.TextColor3=Color3.new(.99607843137255,.76862745098039,.035294117647059)n.TextScaled=true n.Parent=u local l=Instance.new("\084\101\120\116\076\097\098\101\108")l.BackgroundTransparency=1 l.AnchorPoint=Vector2.new(.5,.5)l.Size=UDim2.new(.45,0,.06,0)l.Position=UDim2.new(.678,0,.66,0)l.Text=""l.Font=Enum.Font.Antique l.TextColor3=Color3.new(1.0,1.0,1.0)l.TextScaled=true l.Parent=u local d=Instance.new("\084\101\120\116\076\097\098\101\108")d.BackgroundTransparency=1 d.AnchorPoint=Vector2.new(.5,.5)d.Size=UDim2.new(.45,0,.06,0)d.Position=UDim2.new(.678,0,.735,0)d.Text=""d.Font=Enum.Font.Antique d.TextColor3=Color3.new(1.0,1.0,1.0)d.TextScaled=true d.Parent=u local function E()L={}for Q,h in pairs(t.QuestData.ActiveQuests)do table.insert(L,Q)end for Q,h in pairs(t.QuestData.CompletedQuests)do table.insert(L,Q)end if K==nil then K=L[1]end for Q=1,#L,1 do if not W[Q]then local h=Instance.new("\073\109\097\103\101\066\117\116\116\111\110")h.BackgroundTransparency=1 h.Parent=q h.MouseButton1Down:Connect(function()if B then B=false K=L[Q]E()wait()B=true end end)local N=Instance.new("\073\109\097\103\101\076\097\098\101\108")N.BackgroundTransparency=1 N.Size=UDim2.new(.87096774193548,0,.87096774193548,0)N.SizeConstraint=Enum.SizeConstraint.RelativeYY N.Position=UDim2.new(.0074626865671642,0,.064516129032258,0)N.Parent=h local H=Instance.new("\084\101\120\116\076\097\098\101\108")H.BackgroundTransparency=1 H.AnchorPoint=Vector2.new(1,0)H.Size=UDim2.new(.84328358208955,0,.9,0)H.Position=UDim2.new(1,0,.05,0)H.Font=Enum.Font.Antique H.TextColor3=Color3.new(1,1,1)H.TextScaled=true H.TextXAlignment=Enum.TextXAlignment.Left H.Parent=h W[Q]={h;N,H}end end local h=14.709677419355 local N=math.max(#L,h)for Q,h in pairs(L)do local H=W[Q]H[1].Size=UDim2.new(1,0,1/N,0)H[1].Position=UDim2.new(0,0,(Q-1)/N,0)H[2].Image=t:GetStatusIcon(h)H[3].Text=h if K==h then H[1].Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\051\048\056\054\052\057\056"elseif t:QuestConditonValid(h,"\084\117\114\110\101\100\073\110")then H[1].Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\056\056\049\054\057\053"else H[1].Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\056\056\049\055\050\051"end end if N==h then q.CanvasSize=UDim2.new(0,0,0,0)else q.CanvasSize=UDim2.new(0,0,(N*.067982456140351)*.72,0)end if K then local h=O[K]I.Visible=not t:QuestConditonValid(K,"\084\117\114\110\101\100\073\110")and t.QuestData.SelectedQuest~=K p.Text=K y.Text=h.Description v.Text=t:GetStatusText(K)local N={}for h,H in pairs(h.Rewards or{})do if h=="\066\097\100\103\101"then table.insert(N,Q[H])elseif h=="\088\080"then table.insert(N,tostring(H).." \088\080")elseif h=="\073\116\101\109\115"then for Q,h in pairs(H)do table.insert(N,tostring(h.Amount)..(" "..tostring(h.Name)))end end end l.Text=N[1]or""d.Text=N[2]or""end end r.Button.MouseButton1Down:Connect(function()if B then B=false t:SelectQuest(K)b:FireServer(K)wait()B=true end end)E()t.QuestsChanged:Connect(E)P.InventoryChanged:Connect(E)local w=(script.Parent:WaitForChild("\071\117\105\079\112\101\110\083\116\097\116\101\115")):WaitForChild("\081\117\101\115\116\115")J:Register(g,w)w.Changed:Connect(function()u:TweenPosition(UDim2.new(.5,0,w.Value and.5 or 1.5,0),"\079\117\116","\081\117\097\100",.5,true)end)
--[[
TheNexusAvenger

Displays the active and completed quests.
--]]

local BADGE_NAMES = {
	["Builderman"]           = "BLOXikin #01 Skeleton Builderman",
	["Shedletsky"]           = "BLOXikin #02 Vampire Shedletsky",
	["BrightEyes"]           = "BLOXikin #03 Bella Vampire BrightEyes",
	["ReeseMcBlox"]          = "BLOXikin #04 Witch ReeseMcBlox",
	["OstrichSized"]         = "BLOXikin #05 Mummy OstrichSized",
	["JediTkacheff"]         = "BLOXikin #06 Swamp Monster Jeditkacheff",
	["Sorcus"]               = "BLOXikin #07 Grim Reaper Sorcus",
	["Tarabyte"]             = "BLOXikin #08 Black Cat Tarabyte",
	["StickMasterLuke"]      = "BLOXikin #09 Zombie StickmasterLuke",
	["Fusroblox"]            = "BLOXikin #10 Frankenstein Fusroblox",
	["OnlyTwentyCharacters"] = "BLOXikin #11 Werewolf OnlyTwentyCharacters",
	["SolarCrane"]           = "BLOXikin #12 Ghost SolarCrane",
	["ChiefJustus"]          = "BLOXikin #13 Devil ChiefJustus",
	["Jack-o-lantern"]       = "BLOXikin #14 Jack-o-Lantern ROBLOXian",
	["Miss Pumpkin"]         = "BLOXikin #15 Pumpkin Girl ROBLOXian",
	["Batboy"]               = "BLOXikin #16 Bat ROBLOXian",
	["Batgirl"]              = "BLOXikin #17 Bat Girl ROBLOXian",
	["Spiderboy"]            = "BLOXikin #18 Spider ROBLOXian",
	["Spidergirl"]           = "BLOXikin #19 Spider Girl ROBLOXian",
	["Raven"]                = "BLOXikin #20 Raven ROBLOXian",
	["Spooky Owl"]           = "BLOXikin #21 Owl Girl ROBLOXian",
	["Cthulhu"]              = "BLOXikin #22 Cthulhu",
	["Kaiju"]                = "BLOXikin #23 Kaiju",
	["Ooze Monster"]         = "BLOXikin #24 Ooze Monster",
	["Scarecrow"]            = "BLOXikin #25 Scarecrow",
	["Frankenstein's Bride"] = "BLOXikin #26 Bride of Frankenstein",
	["Gargoyle"]             = "BLOXikin #27 Gargoyle",
	["Yodalien"]             = "BLOXikin #28 Yodalien",
	["Hallo-bot"]            = "BLOXikin #29 Hallo-bot",
	["Invisible Man"]        = "BLOXikin #30 InvisibleMan",
	["Headless Horseman"]    = "BLOXikin #31 Headless Horseman"
}



local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ReplicatedStorageProject = require(ReplicatedStorage:WaitForChild("Project"):WaitForChild("ReplicatedStorage"))

local QuestsData = ReplicatedStorageProject:GetResource("GameData.Quest.Quests")
local ImageEventBinder = ReplicatedStorageProject:GetResource("UI.Button.ImageEventBinder")
local AspectRatioSwitcher = ReplicatedStorageProject:GetResource("UI.AspectRatioSwitcher")
local DisplayOrderController = ReplicatedStorageProject:GetResource("State.DisplayOrderController")
local Quests = ReplicatedStorageProject:GetResource("State.Quests").GetQuests(Players.LocalPlayer)
local Inventory = ReplicatedStorageProject:GetResource("State.Inventory").GetInventory(Players.LocalPlayer)
local SelectQuestEvent = ReplicatedStorageProject:GetResource("GameReplication.QuestReplication.SelectQuest")

local DB = true
local CurrentQuestNames = {}
local SelectedQuest
local ListButtons = {}



--Create the ScreenGui.
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "QuestLogView"
ScreenGui.DisplayOrder = 2
ScreenGui.Parent = script.Parent

--Create the container.
local Background = Instance.new("ImageLabel")
Background.BackgroundTransparency = 1
Background.Position = UDim2.new(0.5,0,1.5,0)
Background.AnchorPoint = Vector2.new(0.5,0.5)
Background.Image = "rbxassetid://132880888"
Background.Parent = ScreenGui

AspectRatioSwitcher.new(ScreenGui,787/634,function()
    Background.Size = UDim2.new(0.9 * (787/634),0,0.9,0)
    Background.SizeConstraint = Enum.SizeConstraint.RelativeYY
end,function()
    Background.Size = UDim2.new(0.9,0,0.9/(787/634),0)
    Background.SizeConstraint = Enum.SizeConstraint.RelativeXX
end)

local QuestsScroll = Instance.new("ScrollingFrame")
QuestsScroll.BackgroundTransparency = 1
QuestsScroll.BorderSizePixel = 0
QuestsScroll.Size = UDim2.new(0.33,0,0.72,0)
QuestsScroll.Position = UDim2.new(0.0325,0,0.25,0)
QuestsScroll.TopImage = "rbxassetid://5706837205"
QuestsScroll.MidImage = "rbxassetid://5706836960"
QuestsScroll.BottomImage = "rbxassetid://5706836746"
QuestsScroll.Parent = Background

local MakeActiveImage = Instance.new("ImageLabel")
MakeActiveImage.BackgroundTransparency = 1
MakeActiveImage.AnchorPoint = Vector2.new(0.5,0.5)
MakeActiveImage.Size = UDim2.new(150/787,0,47/634)
MakeActiveImage.Position = UDim2.new(0.688,0,0.9,0)
MakeActiveImage.Parent = Background
local MakeActiveButton = ImageEventBinder.new(MakeActiveImage,UDim2.new(1,0,1,0),"rbxassetid://132882115","rbxassetid://132882144","rbxassetid://132882131")

local SelectedQuestNameText = Instance.new("TextLabel")
SelectedQuestNameText.BackgroundTransparency = 1
SelectedQuestNameText.AnchorPoint = Vector2.new(0.5,0.5)
SelectedQuestNameText.Size = UDim2.new(0.45,0,0.051,0)
SelectedQuestNameText.Position = UDim2.new(0.688,0,0.334,0)
SelectedQuestNameText.Text = ""
SelectedQuestNameText.Font = Enum.Font.Antique
SelectedQuestNameText.TextColor3 = Color3.new(254/255,196/255,9/255)
SelectedQuestNameText.TextScaled = true
SelectedQuestNameText.Parent = Background

local SelectedQuestDescriptionText = Instance.new("TextLabel")
SelectedQuestDescriptionText.BackgroundTransparency = 1
SelectedQuestDescriptionText.AnchorPoint = Vector2.new(0.5,0)
SelectedQuestDescriptionText.Size = UDim2.new(0.45,0,0.06,0)
SelectedQuestDescriptionText.Position = UDim2.new(0.688,0,0.375,0)
SelectedQuestDescriptionText.Text = ""
SelectedQuestDescriptionText.Font = Enum.Font.Antique
SelectedQuestDescriptionText.TextColor3 = Color3.new(255/255,255/255,255/255)
SelectedQuestDescriptionText.TextScaled = true
SelectedQuestDescriptionText.Parent = Background

local SelectedQuestStatusText = Instance.new("TextLabel")
SelectedQuestStatusText.BackgroundTransparency = 1
SelectedQuestStatusText.AnchorPoint = Vector2.new(0.5,0.5)
SelectedQuestStatusText.Size = UDim2.new(0.45,0,0.044,0)
SelectedQuestStatusText.Position = UDim2.new(0.688,0,0.45,0)
SelectedQuestStatusText.Text = ""
SelectedQuestStatusText.Font = Enum.Font.Antique
SelectedQuestStatusText.TextColor3 = Color3.new(254/255,196/255,9/255)
SelectedQuestStatusText.TextScaled = true
SelectedQuestStatusText.Parent = Background

local SelectedQuestRewardsHeaderText = Instance.new("TextLabel")
SelectedQuestRewardsHeaderText.BackgroundTransparency = 1
SelectedQuestRewardsHeaderText.AnchorPoint = Vector2.new(0.5,0.5)
SelectedQuestRewardsHeaderText.Size = UDim2.new(0.45,0,0.04,0)
SelectedQuestRewardsHeaderText.Position = UDim2.new(0.678,0,0.585,0)
SelectedQuestRewardsHeaderText.Text = "Quest Rewards"
SelectedQuestRewardsHeaderText.Font = Enum.Font.Antique
SelectedQuestRewardsHeaderText.TextColor3 = Color3.new(254/255,196/255,9/255)
SelectedQuestRewardsHeaderText.TextScaled = true
SelectedQuestRewardsHeaderText.Parent = Background

local SelectedQuestRewards1Text = Instance.new("TextLabel")
SelectedQuestRewards1Text.BackgroundTransparency = 1
SelectedQuestRewards1Text.AnchorPoint = Vector2.new(0.5,0.5)
SelectedQuestRewards1Text.Size = UDim2.new(0.45,0,0.06,0)
SelectedQuestRewards1Text.Position = UDim2.new(0.678,0,0.66,0)
SelectedQuestRewards1Text.Text = ""
SelectedQuestRewards1Text.Font = Enum.Font.Antique
SelectedQuestRewards1Text.TextColor3 = Color3.new(255/255,255/255,255/255)
SelectedQuestRewards1Text.TextScaled = true
SelectedQuestRewards1Text.Parent = Background

local SelectedQuestRewards2Text = Instance.new("TextLabel")
SelectedQuestRewards2Text.BackgroundTransparency = 1
SelectedQuestRewards2Text.AnchorPoint = Vector2.new(0.5,0.5)
SelectedQuestRewards2Text.Size = UDim2.new(0.45,0,0.06,0)
SelectedQuestRewards2Text.Position = UDim2.new(0.678,0,0.735,0)
SelectedQuestRewards2Text.Text = ""
SelectedQuestRewards2Text.Font = Enum.Font.Antique
SelectedQuestRewards2Text.TextColor3 = Color3.new(255/255,255/255,255/255)
SelectedQuestRewards2Text.TextScaled = true
SelectedQuestRewards2Text.Parent = Background



--[[
Updates the quests display.
--]]
local function UpdateDisplay()
    --Get the quests to display.
    CurrentQuestNames = {}
    for QuestName,_ in pairs(Quests.QuestData.ActiveQuests) do
        table.insert(CurrentQuestNames,QuestName)
    end
    for QuestName,_ in pairs(Quests.QuestData.CompletedQuests) do
        table.insert(CurrentQuestNames,QuestName)
    end

    --Select a quest if none is selected.
    if SelectedQuest == nil then
        SelectedQuest = CurrentQuestNames[1]
    end

    --Create list buttons if needed.
    --Buttons aren't removed since completed quests are not removed.
    for i = 1,#CurrentQuestNames do
       if not ListButtons[i] then
           local ListButton = Instance.new("ImageButton")
           ListButton.BackgroundTransparency = 1
           ListButton.Parent = QuestsScroll
           ListButton.MouseButton1Down:Connect(function()
               if DB then
                   DB = false
                   SelectedQuest = CurrentQuestNames[i]
                   UpdateDisplay()
                   wait()
                   DB = true
               end
           end)

           local PumpkinIcon = Instance.new("ImageLabel")
           PumpkinIcon.BackgroundTransparency = 1
           PumpkinIcon.Size = UDim2.new(27/31,0,27/31,0)
           PumpkinIcon.SizeConstraint = Enum.SizeConstraint.RelativeYY
           PumpkinIcon.Position = UDim2.new(2/268,0,2/31,0)
           PumpkinIcon.Parent = ListButton

           local QuestName = Instance.new("TextLabel")
           QuestName.BackgroundTransparency = 1
           QuestName.AnchorPoint = Vector2.new(1,0)
           QuestName.Size = UDim2.new(1 - (42/268),0,0.9,0)
           QuestName.Position = UDim2.new(1,0,0.05,0)
           QuestName.Font = Enum.Font.Antique
           QuestName.TextColor3 = Color3.new(1,1,1)
           QuestName.TextScaled = true
           QuestName.TextXAlignment = Enum.TextXAlignment.Left
           QuestName.Parent = ListButton

           ListButtons[i] = {ListButton,PumpkinIcon,QuestName}           
       end 
    end

    --Update the list.
    local MinimumHeight = 456/31
    local ListLength = math.max(#CurrentQuestNames,MinimumHeight)
    for i,QuestName in pairs(CurrentQuestNames) do
        local ButtonData = ListButtons[i]
        ButtonData[1].Size = UDim2.new(1,0,1/ListLength,0)
        ButtonData[1].Position = UDim2.new(0,0,(i - 1)/ListLength,0)
        ButtonData[2].Image = Quests:GetStatusIcon(QuestName)
        ButtonData[3].Text = QuestName

        if SelectedQuest == QuestName then
            ButtonData[1].Image = "rbxassetid://133086498"
        elseif Quests:QuestConditonValid(QuestName,"TurnedIn") then
            ButtonData[1].Image = "rbxassetid://132881695"
        else
            ButtonData[1].Image = "rbxassetid://132881723"
        end
    end
    if ListLength == MinimumHeight then
        QuestsScroll.CanvasSize = UDim2.new(0,0,0,0)
    else
        QuestsScroll.CanvasSize = UDim2.new(0,0,ListLength * (31/456) * 0.72,0)
    end

    --Update the selected quest display.
    if SelectedQuest then
        --Set the base text.
        local QuestData = QuestsData[SelectedQuest]
        MakeActiveImage.Visible = (not Quests:QuestConditonValid(SelectedQuest,"TurnedIn")) and (Quests.QuestData.SelectedQuest ~= SelectedQuest)
        SelectedQuestNameText.Text = SelectedQuest
        SelectedQuestDescriptionText.Text = QuestData.Description
        SelectedQuestStatusText.Text = Quests:GetStatusText(SelectedQuest)

        --Set the rewards.
        local Rewards = {}
        for RewardType,Reward in pairs(QuestData.Rewards or {}) do
            if RewardType == "Badge" then
                table.insert(Rewards,BADGE_NAMES[Reward])
            elseif RewardType == "XP" then
                table.insert(Rewards,tostring(Reward).." XP")
            elseif RewardType == "Items" then
                for _,Item in pairs(Reward) do
                    table.insert(Rewards,tostring(Item.Amount).." "..tostring(Item.Name))
                end
            end
        end
        SelectedQuestRewards1Text.Text = Rewards[1] or ""
        SelectedQuestRewards2Text.Text = Rewards[2] or ""
    end
end



--Connect setting the active quest.
MakeActiveButton.Button.MouseButton1Down:Connect(function()
    if DB then
        DB = false
        Quests:SelectQuest(SelectedQuest)
        SelectQuestEvent:FireServer(SelectedQuest)
        wait()
        DB = true
    end
end)

--Connect updating the display.
UpdateDisplay()
Quests.QuestsChanged:Connect(UpdateDisplay)
Inventory.InventoryChanged:Connect(UpdateDisplay)

--Connect opening and closing the window.
local OpenValue = script.Parent:WaitForChild("GuiOpenStates"):WaitForChild("Quests")
DisplayOrderController:Register(ScreenGui,OpenValue)
OpenValue.Changed:Connect(function()
    Background:TweenPosition(UDim2.new(0.5,0,OpenValue.Value and 0.5 or 1.5,0),"Out","Quad",0.5,true)
end)