local a=200 local d={[-1]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053";"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053";"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053";"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053";"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\053\057\057\053","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\049\054\050\051\057"},[0]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\050\052\054"};[1]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\050\052\054"};[2]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\056\053\057\048\054"};[3]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\051\055\051"},[4]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\051\053\053"};[5]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\051\054\048"};[6]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\051\052\057"},[7]={"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\052\053\049";"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\052\052\050";"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\048\056\053\055\052\050\052"}}local T={[0]=Color3.new(0,1,0),[1]=Color3.new(1,0,0);[2]=Color3.new(0,0,1)}local j=game:GetService("\080\108\097\121\101\114\115")local D=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local p=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local X=require((D: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 G=X:GetResource("\069\120\116\101\114\110\097\108\085\116\105\108\046\078\101\120\117\115\073\110\115\116\097\110\099\101\046\078\101\120\117\115\079\098\106\101\099\116")local B=X:GetResource("\071\097\109\101\068\097\116\097\046\071\101\110\101\114\097\116\105\111\110\046\077\097\112\067\101\108\108\115")local g=X:GetResource("\071\097\109\101\068\097\116\097\046\071\101\110\101\114\097\116\105\111\110\046\077\097\112\067\111\110\102\105\100\101\110\099\101")local m=X:GetResource("\071\097\109\101\068\097\116\097\046\071\101\110\101\114\097\116\105\111\110\046\084\101\108\101\112\111\114\116\076\111\099\097\116\105\111\110\115")local H=X:GetResource("\071\097\109\101\068\097\116\097\046\071\101\110\101\114\097\116\105\111\110\046\076\097\110\100\109\097\114\107\115")local V=X:GetResource("\083\116\097\116\101\046\080\108\097\121\101\114\068\097\116\097")local R=require(script:WaitForChild("\067\104\097\114\097\099\116\101\114\073\110\100\105\099\097\116\111\114"))local x=X:GetResource("\071\097\109\101\082\101\112\108\105\099\097\116\105\111\110\046\068\117\110\103\101\111\110\082\101\112\108\105\099\097\116\105\111\110\046\083\116\097\114\116\068\117\110\103\101\111\110")local u=X:GetResource("\071\097\109\101\082\101\112\108\105\099\097\116\105\111\110\046\068\117\110\103\101\111\110\082\101\112\108\105\099\097\116\105\111\110\046\069\110\100\068\117\110\103\101\111\110")local K=G:Extend()K:SetClassName("\077\097\112")function K.__new(p,d,T,D)p:InitializeSuper()p.LastX=-1 p.LastY=-1 p.LastGridUpdateX=-1 p.LastGridUpdateY=-1 p.ViewableWidth=6 p.MaxGridWidth=T p.CharacterIndicators={}p.ShowMapConfidence=false p.DiscoveredCellsBoolGrid=D local X=Instance.new("\070\114\097\109\101")X.BackgroundTransparency=1 X.BackgroundColor3=Color3.new(0,0,0)X.BorderSizePixel=0 X.Parent=d p.FullContainer=X local G=Instance.new("\070\114\097\109\101")G.BackgroundTransparency=1 G.BackgroundColor3=Color3.new(0,0,0)G.AnchorPoint=Vector2.new(.5,.5)G.BorderSizePixel=0 G.Parent=d p.CellContainer=G p.CellFrames={}for a=1,T,1 do p.CellFrames[a]={}for d=1,T,1 do local j=Instance.new("\073\109\097\103\101\076\097\098\101\108")j.BackgroundTransparency=1 j.Size=UDim2.new(1/T,0,1/T,0)j.Position=UDim2.new((a-1)/T,0,(T-d)/T,0)j.Parent=G p.CellFrames[a][d]=j end end for d,T in pairs(H)do local j=Instance.new("\073\109\097\103\101\076\097\098\101\108")j.BackgroundTransparency=1 j.Size=UDim2.new(.8/a,0,.8/a,0)j.AnchorPoint=Vector2.new(.5,.5)j.Position=UDim2.new((T[2]-.5)/a,0,((a-T[1])+.5)/a,0)j.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\052\056\053\048\048"j.ZIndex=3 j.Parent=X local D=Instance.new("\084\101\120\116\076\097\098\101\108")D.BackgroundTransparency=1 D.Size=UDim2.new(3,0,.6,0)D.Position=UDim2.new(.5,0,-0.6,0)D.AnchorPoint=Vector2.new(.5,0)D.Font=Enum.Font.Antique D.Text=d D.TextColor3=Color3.new(1,1,1)D.TextScaled=true D.TextXAlignment="\067\101\110\116\101\114"D.ZIndex=3 D.Parent=j end local B=V.GetPlayerData(j.LocalPlayer)p.WarpIconsVisible=B:GetValue("\087\097\114\112\080\117\114\099\104\097\115\101\100");(B:GetValueChangedSignal("\087\097\114\112\080\117\114\099\104\097\115\101\100")):Connect(function()p.WarpIconsVisible=B:GetValue("\087\097\114\112\080\117\114\099\104\097\115\101\100")p:UpdateWarpIconVisibility()end)local g={}p.WarpIcons=g for d,T in pairs(m)do local j=Instance.new("\073\109\097\103\101\066\117\116\116\111\110")j.BackgroundTransparency=1 j.Size=UDim2.new(.8/a,0,.8/a,0)j.AnchorPoint=Vector2.new(.5,.5)j.Position=UDim2.new((T[2]-.5)/a,0,((a-T[1])+.5)/a,0)j.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\052\056\053\051\057"j.ZIndex=4 j.Visible=false j.Parent=X g[d]=j end end function K.GetCellTexture(j,a,T)local D=d[-1]if j.DiscoveredCellsBoolGrid:GetValue(a,T)and(B[a]and B[a][T])then D=d[B[a][T]]or d[-1]end return D[(Random.new(a+T*1000)):NextInteger(1,#D)]end function K.GetCellConfidenceColor(j,a,d)if j.ShowMapConfidence and(g[a]and g[a][d])then return T[g[a][d]]or Color3.new(1,1,1)end return Color3.new(1,1,1)end function K.UpdateWarpIconVisibility(a)for d,T in pairs(a.WarpIcons)do local j=m[d]T.Visible=a.WarpIconsVisible and a.DiscoveredCellsBoolGrid:GetValue(math.floor(j[1]+.5),math.floor(j[2]+.5))end end function K.UpdateCells(a)local d,T=math.floor(a.LastGridUpdateX-a.MaxGridWidth/2),math.floor(a.LastGridUpdateY-a.MaxGridWidth/2)for j,D in pairs(a.CellFrames)do for D,p in pairs(D)do local X,G=d+(D+1),T+(j-1)p.Image=a:GetCellTexture(X,G)p.ImageColor3=a:GetCellConfidenceColor(X,G)end end a:UpdateWarpIconVisibility()end function K.UpdateMap(d)d.FullContainer.Size=UDim2.new(a/d.ViewableWidth,0,a/d.ViewableWidth,0)d.CellContainer.Size=UDim2.new(d.MaxGridWidth/d.ViewableWidth,0,d.MaxGridWidth/d.ViewableWidth,0)local T,j=d.ViewableWidth/2+.5,(a-d.ViewableWidth/2)+.5 local D,p=math.clamp(d.LastX,T,j),math.clamp(d.LastY,T,j)d.LastX,d.LastY=D,p d.FullContainer.Position=UDim2.new((.5+.5/d.ViewableWidth)-p/d.ViewableWidth,0,(.5-.5/d.ViewableWidth)-(a-D)/d.ViewableWidth,0)d.CellContainer.Position=UDim2.new(.5-(p/d.ViewableWidth)%(1/d.ViewableWidth),0,.5-((a-D)/d.ViewableWidth)%(1/d.ViewableWidth),0)local X,G=math.floor(math.clamp(d.LastX,T,j)),math.ceil(math.clamp(d.LastY,T,j))if X~=d.LastGridUpdateX or G~=d.LastGridUpdateY then d.LastGridUpdateX,d.LastGridUpdateY=X,G d:UpdateCells()end end function K.RemoveCharacterIndicator(d,a)local T=d.CharacterIndicators[a]if T then d.CharacterIndicators[a]=nil T:Destroy()end end function K.AddCharacterIndicator(d,a)d:RemoveCharacterIndicator(a)if a.Character then d.CharacterIndicators[a]=R.new(d.FullContainer,a)end end function K.EnableWarping(a)local d for a,T in pairs(a.WarpIcons)do local D=m[a]local X=true T.MouseButton1Down:Connect(function()if X and not d then X=false local a=j.LocalPlayer.Character if a then local j=a:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if a then local a=Instance.new("\085\073\083\099\097\108\101")a.Parent=T for d=1,3,1 do(p:Create(a,TweenInfo.new(.5),{Scale=1.5})):Play()wait(.5);(p:Create(a,TweenInfo.new(.5),{Scale=1})):Play()wait(.5)end a:Destroy()if not d then j.CFrame=(CFrame.new(D[1]*100,3,D[2]*100)*CFrame.Angles(0,-math.pi/2+D[3],0))*CFrame.new(math.random(-10,10),0,math.random(-10,10))end end end wait()X=true end end)end x.OnClientEvent:Connect(function(a,T,j)d=j end)u.OnClientEvent:Connect(function(a,T,j)if d==j then d=nil end end)end function K.SetCenter(T,a,d)T.LastX,T.LastY=a,d T:UpdateMap()end function K.SetViewableWidth(d,a)d.ViewableWidth=a d:UpdateMap()end function K.SetMapConfidence(d,a)d.ShowMapConfidence=a d:UpdateCells()end return K
--[[
TheNexusAvenger

Displays the map of the game.
--]]

local FULL_MAP_SIZE_CELLS = 200
local ID_TO_TEXTURE = {
    [-1] = {"rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131315995","rbxassetid://131316239"}, --Unknown
    [0] = {"rbxassetid://130857246"}, --Custom structure (grass)
    [1] = {"rbxassetid://130857246"}, --Grass
    [2] = {"rbxassetid://132785906"}, --Swamp
    [3] = {"rbxassetid://130857373"}, --Pumpkins
    [4] = {"rbxassetid://130857355"}, --Water
    [5] = {"rbxassetid://130857360"}, --Rock
    [6] = {"rbxassetid://130857349"}, --Road
    [7] = {"rbxassetid://130857451","rbxassetid://130857442","rbxassetid://130857424"}, --House
}
local CONFIDENCE_ID_TO_COLOR = {
    [0] = Color3.new(0,1,0),
    [1] = Color3.new(1,0,0),
    [2] = Color3.new(0,0,1),
}



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

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

local NexusObject = ReplicatedStorageProject:GetResource("ExternalUtil.NexusInstance.NexusObject")
local MapCellData = ReplicatedStorageProject:GetResource("GameData.Generation.MapCells")
local MapConfidenceData = ReplicatedStorageProject:GetResource("GameData.Generation.MapConfidence")
local TeleportLocations = ReplicatedStorageProject:GetResource("GameData.Generation.TeleportLocations")
local Landmarks = ReplicatedStorageProject:GetResource("GameData.Generation.Landmarks")
local PlayerData = ReplicatedStorageProject:GetResource("State.PlayerData")
local CharacterIndicator = require(script:WaitForChild("CharacterIndicator"))
local StartDungeon = ReplicatedStorageProject:GetResource("GameReplication.DungeonReplication.StartDungeon")
local EndDungeon = ReplicatedStorageProject:GetResource("GameReplication.DungeonReplication.EndDungeon")

local Map = NexusObject:Extend()
Map:SetClassName("Map")



--[[
Creates a map.
--]]
function Map:__new(Container,MaxGridWidth,DiscoveredCellsBoolGrid)
    self:InitializeSuper()

    --Set up the initial state.
    self.LastX = -1
    self.LastY = -1
    self.LastGridUpdateX = -1
    self.LastGridUpdateY = -1
    self.ViewableWidth = 6
    self.MaxGridWidth = MaxGridWidth
    self.CharacterIndicators = {}
    self.ShowMapConfidence = false
    self.DiscoveredCellsBoolGrid = DiscoveredCellsBoolGrid

    --Create the containers.
    local FullContainer = Instance.new("Frame")
    FullContainer.BackgroundTransparency = 1
    FullContainer.BackgroundColor3 = Color3.new(0,0,0)
    FullContainer.BorderSizePixel = 0
    FullContainer.Parent = Container
    self.FullContainer = FullContainer

    local CellContainer = Instance.new("Frame")
    CellContainer.BackgroundTransparency = 1
    CellContainer.BackgroundColor3 = Color3.new(0,0,0)
    CellContainer.AnchorPoint = Vector2.new(0.5,0.5)
    CellContainer.BorderSizePixel = 0
    CellContainer.Parent = Container
    self.CellContainer = CellContainer

    --Create the cells.
    self.CellFrames = {}
    for X = 1,MaxGridWidth do
        self.CellFrames[X] = {}
        for Y = 1,MaxGridWidth do
            local Cell = Instance.new("ImageLabel")
            Cell.BackgroundTransparency = 1
            Cell.Size = UDim2.new(1/MaxGridWidth,0,1/MaxGridWidth,0)
            Cell.Position = UDim2.new((X - 1)/MaxGridWidth,0,(MaxGridWidth - Y)/MaxGridWidth,0)
            Cell.Parent = CellContainer
            self.CellFrames[X][Y] = Cell
        end
    end

    --Create the landmarks.
    for Name,LocationData in pairs(Landmarks) do
        local LandmarkIcon = Instance.new("ImageLabel")
        LandmarkIcon.BackgroundTransparency = 1
        LandmarkIcon.Size = UDim2.new(0.8/FULL_MAP_SIZE_CELLS,0,0.8/FULL_MAP_SIZE_CELLS,0)
        LandmarkIcon.AnchorPoint = Vector2.new(0.5,0.5)
        LandmarkIcon.Position = UDim2.new((LocationData[2] - 0.5)/FULL_MAP_SIZE_CELLS,0,(FULL_MAP_SIZE_CELLS - LocationData[1] + 0.5)/FULL_MAP_SIZE_CELLS,0)
        LandmarkIcon.Image = "rbxassetid://131348500"
        LandmarkIcon.ZIndex = 3
        LandmarkIcon.Parent = FullContainer

        local LandmarkText = Instance.new("TextLabel")
        LandmarkText.BackgroundTransparency = 1
        LandmarkText.Size = UDim2.new(3,0,0.6,0)
        LandmarkText.Position = UDim2.new(0.5,0,-0.6,0)
        LandmarkText.AnchorPoint = Vector2.new(0.5,0)
        LandmarkText.Font = Enum.Font.Antique
        LandmarkText.Text = Name
        LandmarkText.TextColor3 = Color3.new(1,1,1)
        LandmarkText.TextScaled = true
        LandmarkText.TextXAlignment = "Center"
        LandmarkText.ZIndex = 3
        LandmarkText.Parent = LandmarkIcon
    end
    
    --Connect warping being purchased.
    local MapPlayerData = PlayerData.GetPlayerData(Players.LocalPlayer)
    self.WarpIconsVisible = MapPlayerData:GetValue("WarpPurchased")
    MapPlayerData:GetValueChangedSignal("WarpPurchased"):Connect(function()
        self.WarpIconsVisible = MapPlayerData:GetValue("WarpPurchased")
        self:UpdateWarpIconVisibility()
    end)

    --Create the warp icons.
    local WarpIcons = {}
    self.WarpIcons = WarpIcons
    for Name,LocationData in pairs(TeleportLocations) do
        local WarpIcon = Instance.new("ImageButton")
        WarpIcon.BackgroundTransparency = 1
        WarpIcon.Size = UDim2.new(0.8/FULL_MAP_SIZE_CELLS,0,0.8/FULL_MAP_SIZE_CELLS,0)
        WarpIcon.AnchorPoint = Vector2.new(0.5,0.5)
        WarpIcon.Position = UDim2.new((LocationData[2] - 0.5)/FULL_MAP_SIZE_CELLS,0,(FULL_MAP_SIZE_CELLS - LocationData[1] + 0.5)/FULL_MAP_SIZE_CELLS,0)
        WarpIcon.Image = "rbxassetid://131348539"
        WarpIcon.ZIndex = 4
        WarpIcon.Visible = false
        WarpIcon.Parent = FullContainer
        WarpIcons[Name] = WarpIcon
    end
end

--[[
Returns the texture to use for a given cell.
--]]
function Map:GetCellTexture(X,Y)
    --Get the ids to pick from.
    local Ids = ID_TO_TEXTURE[-1]
    if self.DiscoveredCellsBoolGrid:GetValue(X,Y) and MapCellData[X] and MapCellData[X][Y] then
        Ids = ID_TO_TEXTURE[MapCellData[X][Y]] or ID_TO_TEXTURE[-1]
    end

    --Return a random texture.
    return Ids[Random.new(X + (Y * 1000)):NextInteger(1,#Ids)]
end

--[[
Returns the color to use for a cell representing
the confidence value. Will return white
if displaying it is disabled.
--]]
function Map:GetCellConfidenceColor(X,Y)
    --Return the color for a cell.
    if self.ShowMapConfidence and MapConfidenceData[X] and MapConfidenceData[X][Y] then
        return CONFIDENCE_ID_TO_COLOR[MapConfidenceData[X][Y]] or Color3.new(1,1,1)
    end

    --Return white (disabled or no data).
    return Color3.new(1,1,1)
end

--[[
Updates the visibility of the warp icons.
--]]
function Map:UpdateWarpIconVisibility()
    for WarpIconName,WarpIcon in pairs(self.WarpIcons) do
        local WarpData = TeleportLocations[WarpIconName]
        WarpIcon.Visible = self.WarpIconsVisible and self.DiscoveredCellsBoolGrid:GetValue(math.floor(WarpData[1] + 0.5),math.floor(WarpData[2] + 0.5))
    end
end

--[[
Updates the cells of the map.
--]]
function Map:UpdateCells()
    local StartX,StartY = math.floor(self.LastGridUpdateX - (self.MaxGridWidth/2)),math.floor(self.LastGridUpdateY - (self.MaxGridWidth/2))
    for XOffset,ImageLabels in pairs(self.CellFrames) do
        for YOffset,ImageLabel in pairs(ImageLabels) do
            local X,Y = StartX + (YOffset + 1),StartY + (XOffset - 1)
            ImageLabel.Image = self:GetCellTexture(X,Y)
            ImageLabel.ImageColor3 = self:GetCellConfidenceColor(X,Y)
        end
    end
    self:UpdateWarpIconVisibility()
end

--[[
Updates the map.
--]]
function Map:UpdateMap()
    --Update the sizes.
    self.FullContainer.Size = UDim2.new(FULL_MAP_SIZE_CELLS/self.ViewableWidth,0,FULL_MAP_SIZE_CELLS/self.ViewableWidth,0)
    self.CellContainer.Size = UDim2.new(self.MaxGridWidth/self.ViewableWidth,0,self.MaxGridWidth/self.ViewableWidth,0)

    --Update the positions.
    local MinMapPos,MaxMapPos = (self.ViewableWidth/2) + 0.5,FULL_MAP_SIZE_CELLS - (self.ViewableWidth/2) + 0.5
    local MapCenterX,MapCenterY = math.clamp(self.LastX,MinMapPos,MaxMapPos),math.clamp(self.LastY,MinMapPos,MaxMapPos)
    self.LastX,self.LastY = MapCenterX,MapCenterY
    self.FullContainer.Position = UDim2.new(0.5 + (0.5/self.ViewableWidth) - (MapCenterY/self.ViewableWidth),0,0.5 - (0.5/self.ViewableWidth) - (((FULL_MAP_SIZE_CELLS - MapCenterX)/self.ViewableWidth)),0)
    self.CellContainer.Position = UDim2.new(0.5 - (((MapCenterY/self.ViewableWidth)) % (1/self.ViewableWidth)),0,0.5 - ((((FULL_MAP_SIZE_CELLS - MapCenterX)/self.ViewableWidth)) % (1/self.ViewableWidth)),0)

    --Update the cells if the display should be updated.
    local NewCellX,NewCellY = math.floor(math.clamp(self.LastX,MinMapPos,MaxMapPos)),math.ceil(math.clamp(self.LastY,MinMapPos,MaxMapPos))
    if NewCellX ~= self.LastGridUpdateX or NewCellY ~= self.LastGridUpdateY then
        self.LastGridUpdateX,self.LastGridUpdateY = NewCellX,NewCellY
        self:UpdateCells()
    end
end

--[[
Removes a character indicator.
--]]
function Map:RemoveCharacterIndicator(Player)
    local Indicator = self.CharacterIndicators[Player]
    if Indicator then
        self.CharacterIndicators[Player] = nil
        Indicator:Destroy()
    end
end

--[[
Adds a character indicator.
--]]
function Map:AddCharacterIndicator(Player)
    --Remove the existing indicator.
    self:RemoveCharacterIndicator(Player)

    --Add the indicator.
    if Player.Character then
        self.CharacterIndicators[Player] = CharacterIndicator.new(self.FullContainer,Player)
    end
end

--[[
Enables being able to use the warp buttons.
--]]
function Map:EnableWarping()
    --Set up the buttons.
    local CurrentDungeon
    for Name,Button in pairs(self.WarpIcons) do
        local LocationData = TeleportLocations[Name]

        --Set up clicking the button.
        local DB = true
        Button.MouseButton1Down:Connect(function()
            if DB and not CurrentDungeon then
                DB = false
                local Character = Players.LocalPlayer.Character
                if Character then
                    local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
                    if Character then
                        --Display the animation.
                        local Scale = Instance.new("UIScale")
                        Scale.Parent = Button
                        for i = 1,3 do
                            TweenService:Create(Scale,TweenInfo.new(0.5),{ Scale = 1.5 }):Play()
                            wait(0.5)
                            TweenService:Create(Scale,TweenInfo.new(0.5),{ Scale = 1 }):Play()
                            wait(0.5)
                        end
                        Scale:Destroy()

                        --Teleport the player.
                        if not CurrentDungeon then
                            HumanoidRootPart.CFrame = CFrame.new(LocationData[1] * 100,3,LocationData[2] * 100) * CFrame.Angles(0,(-math.pi/2) + LocationData[3],0) * CFrame.new(math.random(-10,10),0,math.random(-10,10))
                        end
                    end
                end
                
                wait()
                DB = true
            end
        end)
    end

    --Connect entering and leaving dungeons.
    StartDungeon.OnClientEvent:Connect(function(_,_,Id)
        CurrentDungeon = Id
    end)
    
    EndDungeon.OnClientEvent:Connect(function(_,_,Id)
        if CurrentDungeon == Id then
            CurrentDungeon = nil
        end
    end)
end

--[[
Sets the map's center. Can be decimal.
--]]
function Map:SetCenter(X,Y)
    self.LastX,self.LastY = X,Y
    self:UpdateMap()
end

--[[
Sets the viewable amount of cells in
the X and Y axes.
--]]
function Map:SetViewableWidth(Width)
    self.ViewableWidth = Width
    self:UpdateMap()
end

--[[
Sets the map confidence being visible or not.
--]]
function Map:SetMapConfidence(MapConfidence)
    self.ShowMapConfidence = MapConfidence
    self:UpdateCells()
end



return Map