0% found this document useful (0 votes)
73 views68 pages

Message

The document defines variables and requires modules to set up a game server. It connects events and defines functions for handling things like difficulty calculation, data storage, and generating ropes in the game world.

Uploaded by

hellwwk
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)
73 views68 pages

Message

The document defines variables and requires modules to set up a game server. It connects events and defines functions for handling things like difficulty calculation, data storage, and generating ropes in the game world.

Uploaded by

hellwwk
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
You are on page 1/ 68

local isnewdata = true

local waitingtime = 8
local exit = nil
local forceevent = nil
ReplicatedStorage = game:GetService("ReplicatedStorage")
Library = require(ReplicatedStorage.SharedModules.FE2Library)
local genrope =
require(game.ReplicatedStorage.SharedModules:WaitForChild("GenerateRope"))
local normal,maptest,pro,chaos,chill,testing,startid = Library.getEnabled()
if game.GameId ~= 4989130044 and maptest and
game.ServerStorage:FindFirstChild("MapTestMapPack") then
game.ServerStorage:WaitForChild("Maps"):Destroy()
game.ServerStorage:WaitForChild("UnloadedMaps"):Destroy()
for i,v in ipairs(game.ServerStorage.MapTestMapPack:GetChildren()) do
v.Parent = game.ServerStorage
end
game.ServerStorage.MapTestMapPack:Destroy()
end
if game.GameId ~= 4989130044 and maptest and
ReplicatedStorage:FindFirstChild("MapTestAnimIDs") then
ReplicatedStorage:WaitForChild("AnimIDs"):Destroy()
ReplicatedStorage:WaitForChild("MapTestAnimIDs").Name = "AnimIDs"
end
--badge only for Testing place
if normal or game.PlaceId == 15016276688 then
game.Players.PlayerAdded:connect(function(player)
task.wait(5)
game:GetService("BadgeService"):AwardBadge(player.userId,5171386591)
end)
end

local MapStorage = game.ServerStorage:WaitForChild("Maps")


local MapResources = game.ServerStorage.MapResources
local Modules = game.ServerScriptService:WaitForChild("Modules")
MapScript = require(script.Parent:WaitForChild("MapScript"))
MapInitModule = require(Modules:WaitForChild("Core"):WaitForChild("MapInitModule"))
ReqPasskey = ReplicatedStorage.Remote:WaitForChild("ReqPasskey")
UpdateGameState = ReplicatedStorage.Remote:WaitForChild("UpdateGameState")
ReqItemData = ReplicatedStorage.Remote:WaitForChild("ReqItemData")
ReqItemDataOLD = ReplicatedStorage.Remote:WaitForChild("ReqItemData_OLD")
ReqVIPStatus = ReplicatedStorage.Remote:WaitForChild("ReqVIPStatus")
AddedWaiting = ReplicatedStorage.Remote:WaitForChild("AddedWaiting")
RemoveWaiting = ReplicatedStorage.Remote:WaitForChild("RemoveWaiting")
LoadedMap = ReplicatedStorage.Remote:WaitForChild("LoadedMap")
Survived = ReplicatedStorage.Remote:WaitForChild("Survived")
ConfirmItem = ReplicatedStorage.Remote:WaitForChild("ConfirmItem")
UpdSpectate = ReplicatedStorage.Remote:WaitForChild("UpdSpectate")
UpdPlayerData = game.ReplicatedStorage.Remote:WaitForChild("UpdPlayerData")
ShowSummary = game.ReplicatedStorage.Remote:WaitForChild("ShowSummary")
ReqUserMapList = ReplicatedStorage.Remote.TEST:WaitForChild("ReqUserMapList")
ReqTestMap = ReplicatedStorage.Remote.TEST:WaitForChild("ReqTestMap")
ReqAirToggle = ReplicatedStorage.Remote.TEST:WaitForChild("ReqAirToggle")
ReqMapWhitelist = ReplicatedStorage.Remote.TEST:WaitForChild("ReqMapWhitelist")
ReqLoadedMaps = ReplicatedStorage.Remote.TEST:WaitForChild("ReqLoadedMaps")
GetMapVals = workspace.Multiplayer:WaitForChild("GetMapVals")
Alert = ReplicatedStorage.Remote:WaitForChild("Alert")
Notify = ReplicatedStorage.Remote:WaitForChild("Notify")
StartClientMapTimer = ReplicatedStorage.Remote:WaitForChild("StartClientMapTimer")
BuyDifLock = ReplicatedStorage.Remote:WaitForChild("BuyDifLock")
Sound = ReplicatedStorage.Remote:WaitForChild("Sound")
LvlUp = ReplicatedStorage.Remote:WaitForChild("LvlUp")
ReqRebirth = ReplicatedStorage.Remote:WaitForChild("ReqRebirth")
ReqCode = ReplicatedStorage.Remote:WaitForChild("ReqCode")
ReplicatedStorage.Config:SetAttribute("BuildVersion", tostring(game.PlaceVersion))
--[[Config = ReplicatedStorage.Config:GetAttribute("LobbyMusic")]]
local AdminEvent = game.ReplicatedStorage.Remote.Admin:FindFirstChild("AdminEvent")
-- Never Ended up using FindFirstChild
--Dont remove this: This is for admin
--SECURITY WARNING: THIS ADMINEVENT COULD BE VULNRABILITY FOR EXPLOITER
if AdminEvent then
AdminEvent.OnServerEvent:Connect(function(plr,action,arg1,arg2)
--[[if game.GameId ~= 4989130044 then
Alert:FireClient(plr, "Unavailable in this place to prevent
exploiting.")
return
end]] --NOTE UWU
if action == "Bring" then
arg1.Character.HumanoidRootPart.CFrame =
plr.Character.HumanoidRootPart.CFrame
elseif action == "Teleport" then
plr.Character.HumanoidRootPart.CFrame =
arg1.Character.HumanoidRootPart.CFrame
elseif action == "Kill" then
Alert:FireClient(arg1, arg2)
arg1.Character.Humanoid.Health = 0
elseif action == "ServerMessage" then

game.ReplicatedStorage.Remote.Admin.AdminEvent:FireAllClients(arg2)
elseif action == "GiveGems" then
Alert:FireClient(arg1, "You given " .. arg2 .. " gems by " ..
plr.Name)
MainData[arg1.Name].plrData.stats.gems =
MainData[arg1.Name].plrData.stats.gems + arg2
arg1:LoadCharacter()
elseif action == "GiveCoins" then
Alert:FireClient(arg1, "You given " .. arg2 .. " coins by " ..
plr.Name)
MainData[arg1.Name].plrData.stats.coins =
MainData[arg1.Name].plrData.stats.coins + arg2
arg1:LoadCharacter()
elseif action == "GiveLVL" then
Alert:FireClient(arg1, "You given " .. arg2 .. " Levels by " ..
plr.Name)
MainData[arg1.Name].plrData.stats.level =
MainData[arg1.Name].plrData.stats.level + arg2
arg1:LoadCharacter()
elseif action == "GiveXP" then
Alert:FireClient(arg1, "You given " .. arg2 .. " XPs by " ..
plr.Name)
MainData[arg1.Name].plrData.stats.xp =
MainData[arg1.Name].plrData.stats.xp + arg2
arg1:LoadCharacter()
elseif action == "GiveRebirth" then
Alert:FireClient(arg1, "You given " .. arg2 .. " Rebirths by " ..
plr.Name)
MainData[arg1.Name].plrData.stats.rebirth =
MainData[arg1.Name].plrData.stats.rebirth + arg2
arg1:LoadCharacter()
elseif action == "ResetData" then
if arg2 == true then
Alert:FireClient(arg1, "Your data has been resetted by " ..
plr.Name)
MainData[arg1.Name].plrData = DataFormatting.checkData()
UpdPlayerData:FireClient(arg1, MainData[arg1.Name].plrData)
else
AdminEvent:FireClient(plr, "ResetData", arg1)
end
end
end)
end
--
--Edit 4 tests--
RemoveLoadedMap = ReplicatedStorage.Remote.TEST:WaitForChild("RemoveLoadedMap")
UpdLoadedMaps = ReplicatedStorage.Remote.TEST:WaitForChild("UpdLoadedMaps")
UpdLoadScreen = ReplicatedStorage.Remote:WaitForChild("UpdLoadScreen")
MapDebug = ReplicatedStorage.Remote.TEST:WaitForChild("MapDebug")
-----
ExitTitle = ReplicatedStorage.Remote.ExitTitle
RescueTrigger = ReplicatedStorage.Remote.RescueTrigger
ReqTele = ReplicatedStorage.Remote.ReqTele
UpdIngameStats = ReplicatedStorage.Remote.UpdIngameStats
UpdGoalLocator = ReplicatedStorage.Remote.UpdGoalLocator
----------------
DataStoreService = game:GetService("DataStoreService")

local MonthNames =
{"January","February","March","April","May","June","July","August","September","Oct
ober","November","December"}
LBString = ""
PassKey = math.random(0, 99999)
Datastring = "Main" --DONT CHANGE!!! \77\97\105\110\10
Playing = false
Players = game:GetService("Players")
Waiting = {}
Loaded = {}
curPlaying = {}
Survivors = {}
Intensity = 1 -- math.clamp(NewIntensity,1,6.99)
CurDif = 0 -- math.floor(Intensity) - 1
PlayedDif = 1
LockedCurDif = 0
LockedCurDifLeft = 0
BoostedIntensity = 0
plrSumData = {}
plrBtnData = {}
plrGroupBtnData = {}
playerBtnData2 = {}
MainData = {}
PlrCaches = {}
DataFormatting = require(script.Parent.Modules.Core.DataFormatting)
PlrDatStrMod = require(script.Parent.Modules.Core.PlayerDataStore)
itemDataL = require(script.Parent.Modules.Core.ItemData).fetchItemData()--Updated
APD = {}
local lockcounted = false
local tabDif = {
"Easy",
"Normal",
"Hard",
"Insane",
"Crazy",
"Crazy+",
}
local difColors = {
Color3.fromRGB(85, 255, 127),
Color3.fromRGB(255, 255, 127),
Color3.fromRGB(255, 85, 127),
Color3.fromRGB(170, 85, 255),
Color3.fromRGB(215, 131, 59),
Color3.fromRGB(211, 84, 0),
}
local difBalance = {
0.4, -- 1. easy
0.5, -- 2. normal
0.6, -- 3. hard
0.65, -- 4. insane
1.5, -- 5. crazy
2, -- 6. crazy+
}

------<< \\Generate Rope

--[[function generateRope(ropeModel)
if ropeModel:IsA("Model") and ropeModel.Name == "_Rope" then
genrope:renderRope(ropeModel)
end
end

for i, ropeModel in next, game.Workspace:GetDescendants() do


generateRope(ropeModel)
end

game.Workspace.DescendantAdded:connect(generateRope)]]

------>>

local function getIntensityChange(performance, difficulty, boost) -- (Survivors /


Round Players), floored Intensity, final Intensity Boost
local difficulty = difficulty and math.floor(math.clamp(difficulty,1,6)) or
math.floor(math.clamp(Intensity,1,6))
local boost = boost or 0
return tonumber(("%.2f"):format(tonumber(("%.2f"):format(performance)) -
(difBalance[difficulty] or 0.5) + boost))
end
local function ActualDif(ints)
return math.clamp(tonumber(("%d"):format(ints)), 1, 6)
end
local difInfos = Library.getDifInfo()
if maptest then
--Config = 11537794291
ReplicatedStorage.Config:SetAttribute("LobbyMusic", game.GameId ~= 4989130044
and 11537794291 or 12774256034)
elseif pro then
--Config = 14430493826
ReplicatedStorage.Config:SetAttribute("LobbyMusic", game.GameId ~= 4989130044
and 14430493826 or 12774256034)
end
if maptest and game.ServerScriptService.Modules:FindFirstChild("MapTest") and
game.ServerScriptService.Modules.MapTest:FindFirstChild("Initialize") then
spawn(function()
require(game.ServerScriptService.Modules.MapTest.Initialize)
end)
end
if game:GetService("ServerScriptService").Modules:FindFirstChild("FE2_Maps") and
game:GetService("ServerScriptService").Modules.FE2_Maps:FindFirstChild("Initialize"
) then
spawn(function()
require(game.ServerScriptService.Modules.FE2_Maps.Initialize)
end)
end
local SumDifVal = {
50,
75,
125,
200,
500,
750,
}
--local SF = game.ServerStorage.OldShop
local NSF = game.ReplicatedStorage:FindFirstChild("Items")
--Setup Maps--
Maps0 = {}
Maps1 = {}
Maps2 = {}
Maps3 = {}
Maps4 = {}
Maps5 = {}
local voting = false
local maxguid = 0
local voteStats = {
mapData = {},
-- = { {
-- name = "MapName", ID = voteID<string/number>,
-- imgID = MapImage<number>, displayMap = true,
-- cooldown = false, locked = false, unlockCost = 15,
-- extraVoteCost = 10
-- }, ... }
pVotes = {}
-- = { [UserId<string>] = { mapID = voteID<string/number>, voteCount = number
}, ... }
}
local mapDatas = {}
local mappedMapData = {}
--local mappedMaps = {}
--[[local function addMapVoteInfo(map)
if not map:FindFirstChild("Settings") then
return
end
if mappedMapData[map] ~= nil then
return
end
maxguid = maxguid + 1
local thisId = maxguid
local mapdata = {
name = map.Settings:GetAttribute("MapName") or
(map.Settings:FindFirstChild("MapName") and map.Settings.MapName.Value) or '???',
ID = thisId,
imgID = map.Settings:GetAttribute("MapImage") or
(map.Settings:FindFirstChild("MapImage") and map.Settings.MapImage.Value) or 0,
difficulty = map.Settings:GetAttribute("Difficulty") or
(map.Settings:FindFirstChild("Difficulty") and map.Settings.Difficulty.Value) or 6,
displayMap = false,
cooldown = false,
cooldowned = false,
locked = false,
unlockCost = 0,
extraVoteCost = 0,
Map = map,
specialMap = (map.Settings:FindFirstChild("Highlight") and
map.Settings.Highlight.Value) or false
}
mappedMapData[map] = mapdata
--mappedMaps[mapdata] = map
table.insert(mapDatas, mapdata)
end]]
local cooldownData = {}
local function coolfunc(self)
if cooldownData[self.Map] == nil then
cooldownData[self.Map] = {}
end
cooldownData[self.Map].cooldown = self.cooldown
cooldownData[self.Map].cooldowned = self.cooldowned
end
local function createMapVoteInfo(map)
if not map:FindFirstChild("Settings") then
return
end
--if mappedMapData[map] ~= nil then
-- return
--end
maxguid = maxguid + 1
local thisId = maxguid
local cooldownL = cooldownData[map] and cooldownData[map] or {cooldown =
false, cooldowned = false}
local mapdata = {
name = map.Settings:GetAttribute("MapName") or
(map.Settings:FindFirstChild("MapName") and map.Settings.MapName.Value) or '???',
ID = thisId,
imgID = map.Settings:GetAttribute("MapImage") or
(map.Settings:FindFirstChild("MapImage") and map.Settings.MapImage.Value) or 0,
difficulty = map.Settings:GetAttribute("Difficulty") or
(map.Settings:FindFirstChild("Difficulty") and map.Settings.Difficulty.Value) or 6,
displayMap = false,
cooldown = cooldownL.cooldown,
cooldowned = cooldownL.cooldowned,
locked = false,
unlockCost = 0,
extraVoteCost = 0,
layout = 1,
Map = map,
specialMapName = nil,
specialMapColor = nil,
specialMap = (map.Settings:FindFirstChild("Highlight") and
map.Settings.Highlight.Value)
or map.Settings:GetAttribute("Highlight")
or (map.Settings:FindFirstChild("Seasonal") and
map.Settings.Seasonal.Value)
or map.Settings:GetAttribute("Seasonal") or false,
updateData = coolfunc,
}

local SpecialMapsVars = {
"Highlight",
"Seasonal"
}

local SpecialMaps = {
"Featured Map",
"Seasonal Map"
}

local SpecialMapsColors = {
Color3.fromRGB(85, 170, 127),
Color3.fromRGB(166, 231, 255)
}

if mapdata.specialMap then
for k, v in next, SpecialMapsVars do
if (map.Settings:FindFirstChild(v) and map.Settings[v].Value) or
map.Settings:GetAttribute(v) then
mapdata.specialMapName = SpecialMaps[k]
mapdata.specialMapColor = SpecialMapsColors[k]
end
end
end

--[[if mapdata.specialMap and (map.Settings:FindFirstChild("Highlight") and


map.Settings.Highlight.Value) or map.Settings:GetAttribute("Highlight") then
mapdata.specialMapName = "Featured Map"
mapdata.specialMapColor = Color3.fromRGB(85, 170, 127)
elseif mapdata.specialMap and (map.Settings:FindFirstChild("Seasonal") and
map.Settings.Seasonal.Value) or map.Settings:GetAttribute("Seasonal") then
mapdata.specialMapName = "Seasonal Map"
mapdata.specialMapColor = Color3.fromRGB(166, 231, 255)
end]]

return mapdata
--mappedMapData[map] = mapdata
--mappedMaps[mapdata] = map
--table.insert(mapDatas, mapdata)
end
--[[local function removeMapVoteInfo(map)
if mappedMapData[map] == nil then
return
end
if voting == true then
warn("Map is voting but removeMapVoteInfo being called.")
end
(game.GameId == 4989130044 and task.spawn or pcall)(table.remove, mapDatas,
table.find(mapDatas, mappedMapData[map]))
-- ^ outputs error on testing place or not
--mappedMaps[mappedMapData[map]-] = nil
mappedMapData[map] = nil
end]]
local children = MapStorage:GetChildren()
for i, child in ipairs(children) do
--[[if child.Settings:FindFirstChild("Difficulty") then
table.insert(getfenv()["Maps" ..
math.clamp(child.Settings.Difficulty.Value,1,6) - 1], child)
elseif child.Settings:GetAttribute("Difficulty") then
table.insert(getfenv()["Maps" ..
math.clamp(child.Settings:GetAttribute("Difficulty"),1,6) - 1], child)
end]]
if child and child:FindFirstChild("Settings") then
--task.spawn(addMapVoteInfo,child)
if child.Settings:FindFirstChild("Difficulty") then
local diff = math.clamp(tonumber(child.Settings.Difficulty.Value)
or 6,1,6)
local mapt = diff == 1 and Maps0 or (diff == 2 and Maps1 or (diff
== 3 and Maps2 or (diff == 4 and Maps3 or (diff == 5 and Maps4 or diff == 6 and
Maps5 or Maps5))))
table.insert(mapt, child)
elseif child.Settings:FindFirstChild("Intensity") then
local diff = math.clamp(tonumber(child.Settings.Intensity.Value)
or 6,1,6)
local mapt = diff == 1 and Maps0 or (diff == 2 and Maps1 or (diff
== 3 and Maps2 or (diff == 4 and Maps3 or (diff == 5 and Maps4 or diff == 6 and
Maps5 or Maps5))))
table.insert(mapt, child)
elseif child.Settings:GetAttribute("Difficulty") or
child.Settings:GetAttribute("Intensity") then
local diff =
math.clamp(tonumber(child.Settings:GetAttribute("Difficulty")) or
tonumber(child.Settings:GetAttribute("Intensity")) or 6,1,6)
local mapt = diff == 1 and Maps0 or (diff == 2 and Maps1 or (diff
== 3 and Maps2 or (diff == 4 and Maps3 or (diff == 5 and Maps4 or diff == 6 and
Maps5 or Maps5))))
table.insert(mapt, child)
end
if (not child.Settings:FindFirstChild("Creator")) and
type(child.Settings:GetAttribute("Creator")) ~= 'string' then
child.Settings:SetAttribute("Creator", '')
end
if child.Settings:FindFirstChild("Creator") then
child.Settings:SetAttribute("Creator",
child.Settings.Creator.Value)
end
if not child.Settings:GetAttribute("AssetCount") then
child.Settings:SetAttribute("AssetCount", 0)
delay(0, function()
local store = child
child.Settings:SetAttribute("AssetCount",
countParts(store))
end)
end
else
if child then
game:GetService("TestService"):Error("Missing 'Settings' Folder
in '" .. child.Name .. "'")
child:Destroy()
else
game:GetService("TestService"):Error("Crazy error has occured,
loaded map is not cached / unable to load with lua.")
end
end
--if not child.Settings:GetAttribute("Creator") then
-- child.Settings:SetAttribute("Creator", '???')
--end
end
Maps = {
[1] = Maps0,
[2] = Maps1,
[3] = Maps2,
[4] = Maps3,
[5] = Maps4,
[6] = Maps5,
}
PAS = 0
local playeds = {}
local loadingmsg = "Waiting for Server"
local start = tick()
local voteSkip = nil
local votedFirst = false
function startNewVote(diff)
votedFirst = false
local difDatas = {}
local sortedmaps = {}
for i, v in pairs(Maps[tonumber(("%d"):format(diff))]) do
local data = createMapVoteInfo(v)
if data then
table.insert(difDatas, data)
end
end
local allcooldowning = true
for i, v in pairs(difDatas) do
if v then
v.displayMap = false
v.locked = false
if v.cooldown == true and v.cooldowned == true then
v.layout = 2
v.cooldown = false
v.cooldowned = false
end
if v.cooldown == true and v.cooldowned == false then
v.layout = 2 --note layout fix
v.cooldowned = true
end
if v.cooldown == false then
v.layout = 2
allcooldowning = false
end
v:updateData()
table.insert(sortedmaps, v)
--if math.clamp(tonumber(v.difficulty),1,6) ==
math.floor(math.clamp(diff,1,6)) then
-- table.insert(sortedmaps, v)
--end
end
end
if allcooldowning == true then
for i, v in pairs(sortedmaps) do
if v then
v.layout = 2
v.cooldown = false
v.cooldowned = false
v:updateData()
end
end
end
if #sortedmaps <= 0 then
warn("Picked Maps is empty, it may occur error.")
end
if #sortedmaps == 1 then
voting = false
voteSkip = sortedmaps[1].Map
return
end
local pickedMaps = {}
if #sortedmaps >= 8 then --originally there was number 8.
for i = 1, 8 do
local randomized = math.random(1,#sortedmaps)
table.insert(pickedMaps,sortedmaps[randomized])
table.remove(sortedmaps,randomized)
end
for i,v in pairs(pickedMaps) do
v.displayMap = true
end
else
for i,v in pairs(sortedmaps) do
v.displayMap = true
end
pickedMaps = sortedmaps
end
if ((not maptest) or game.PlaceId == 123123123) and #pickedMaps >= 5 then --
PLACE ID LATER HERE IG
local maxLock = #pickedMaps - 3
local cnt = 1
for i = maxLock, 1, -1 do
local v = pickedMaps[i]
if v then
v.locked = true
v.unlockCost = math.clamp(cnt * 10, 10, 30)
cnt = cnt + 1
end
end
end
voteStats.mapData = pickedMaps
voteStats.pVotes = {}
voting = true
--ReplicatedStorage.Remote.NewMapVote:FireAllClients(voteStats, voting)
pcall(function()
for i, player in next, Survivors do
if player then
ReplicatedStorage.Remote.NewMapVote:FireClient(player,
voteStats, voting)
end
end
end)
pcall(function()
for i, player in next, Waiting do
if player then

ReplicatedStorage.Remote.NewMapVote:FireAllClients(voteStats)
end
end
end)
end
local function clearVoteSkip()
voteSkip = nil
end
function pickMap()
if voteSkip ~= nil then
return voteSkip, clearVoteSkip()
end
if voting == true then
voting = false
votedFirst = false
local pickables = {}
local votes = {}
local maxvotes = 0
for i, mapData in next, voteStats.mapData do
if mapData.locked == false then
local voteCount = 0
for i, v in next, voteStats.pVotes do
if v.mapID == mapData.ID then
voteCount = voteCount + v.voteCount
end
end
table.insert(votes, {mapData = mapData, voteCount =
voteCount})
if maxvotes < voteCount then
maxvotes = voteCount
end
end
end
for i, vote in next, votes do
if vote.voteCount and vote.voteCount == maxvotes then
table.insert(pickables, vote.mapData.Map)
end
end
local chosen = pickables[math.random(1,#pickables)]
if cooldownData[chosen] ~= nil then
votes.layout = 2
cooldownData[chosen].cooldown = true
end
return chosen
end
end
---
local function tweenModel(model, CF)
local info = TweenInfo.new()
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()

CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local tween = game:GetService("TweenService"):Create(CFrameValue, info, {
Value = CF
})
tween:Play()

tween.Completed:connect(function()
CFrameValue:Destroy()
end)
end
------------------------------------------------------------
local function getPlayerFromCharacter(character)
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if player.Character == character then
return player
end
end
end
------------------------------------------------------------
function UpdPlayerDataFunc(player)
local data = {}
for name, value in pairs(DataFormatting.newTemplate()) do
data[name] = MainData[player.Name]:Get(name)
end
UpdPlayerData:FireClient(player, data)
end
------------------------------------------------------------
local Ingamestats = {
boostingEnabled = true,
currentButton = 0,
currentPlayers = 0,
difficulty = 1,
intensity = 1,
mapImg = 0,
gameStatus = "intermission", -- intermission or ingame
intBoostCurrentCost = 5,
lockDir = LockedCurDif,
lockDirLeft = LockedCurDifLeft,
mapName = nil,
timerDuration = waitingtime,
timerStart = 0,
totalButtons = 0,
totalPlayers = 0
}
local function UpdIngameStatsFunc()
Ingamestats.lockDirLeft = LockedCurDifLeft
Ingamestats.currentPlayers = #curPlaying -- + #Survivors
Ingamestats.lockDir = LockedCurDif
--Ingamestats.intensity = Intensity
task.spawn(function()
if Ingamestats.timerDuration == -1 then

workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage:TweenSize(UDim2.new(1
, 0, 1, 0), "Out", "Linear", 0, true)
else

workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage.Size =
UDim2.new(1 - ((tick() - Ingamestats.timerStart) / Ingamestats.timerDuration), 0,
1, 0)
workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage:TweenSize(UDim2.new(0
, 0, 1, 0), "Out", "Linear", Ingamestats.timerStart + Ingamestats.timerDuration -
tick(), true)
end
end)
UpdIngameStats:FireAllClients(Ingamestats)
end
spawn(function()
local srvtimeval =
ReplicatedStorage:WaitForChild("Flags"):WaitForChild("ServerTime")
while task.wait() do
srvtimeval.Value = tick()
end
end)
------------------------------------------------------------
local function UpdateCurPlaying(skip)
UpdIngameStatsFunc()
game.ServerStorage.Bindables.UpdIngamePlayerCount:Fire(#curPlaying)
if #curPlaying == 1 and not skip then
Sound:FireClient(curPlaying[1],1278127816,0.5,1.3)
Alert:FireClient(curPlaying[1],"You're the last player
alive!",Color3.fromRGB(192, 57, 43))
end
end
------------------------------------------------------------
local function UpdSpectateFired(player, pass)
--[[
if -PassKey ~= pass then
Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
return
end
--]]
local SPCRETURN = {}
for i = 1, #curPlaying do
if player ~= curPlaying[i] then
table.insert(SPCRETURN, curPlaying[i])
end
end
return SPCRETURN, tick() - start
end

UpdSpectate.OnServerInvoke = UpdSpectateFired
------------------------------------------------------------
local function onReqPasskeyFired(player)
return PassKey
end

local function onCharacterAdded(character)


local plr = getPlayerFromCharacter(character)
script.Bubbles:Clone().Parent = character.Head
local humanoid = character:WaitForChild("Humanoid")
spawn(function()
local plrinfo = script.PlrInfo:Clone()
plrinfo.Parent = character
plrinfo.Adornee = humanoid.RootPart
plrinfo.PlayerToHideFrom = nil
plrinfo:WaitForChild("Update").Disabled = false
while MainData[plr.Name].plrData == nil do
wait()
end

plrinfo:WaitForChild("Update"):WaitForChild("ShowInfo"):Fire(plr,MainData[plr.Name]
.plrData,false)
end)
end

function FormatSummaryData(sumtable, died, totalxp)


local mapstats = {}
local morecoins = 0
local moregems = 0
for _, mapsum in next, sumtable do
local stat = {}
local gotxp = 0
for i,v in next, mapsum do
if i ~= "MapInfo" and i ~= "Buttons" and i ~= "Survived" and i ~=
"Rescue" and type(v) == 'table' then
gotxp = gotxp + (v[2] * (v[3] ~= nil and v[3] or 1))
else
stat[i] = v
end
if i == "Rescue" then
moregems = moregems + v.Reward
end
end
if stat.Survived == nil then
stat.Survived = {
Time = 0,
Position = 0,
AllPlayers = stat.MapInfo.AllPlayers
}
end
stat.XP = {
Bonus = 0,
Total = gotxp
}
table.insert(mapstats,stat)
end
return mapstats, died, totalxp, 1, Library.getXPCoinAward(totalxp) +
morecoins, Library.getXPGemAward(totalxp) + moregems
--survmaps, died, awardedxp, awardcounts, awardedcoins, awardedgems
end

function onCharacterLoaded(character)
local plr = getPlayerFromCharacter(character)
if MainData[plr.Name] and MainData[plr.Name].plrData and
MainData[plr.Name].plrData.equipped then
for tab, check in pairs(MainData[plr.Name].plrData.equipped) do
--[[local descendants = SF:GetDescendants()
for index, descendant in pairs(descendants) do
if descendant.Parent.Parent.Name == "Shop" then
if descendant.ID.Value == check then
Equipt(plr, descendant, true)
end
end
end]]
Equipt(plr, check, true)
end
end
end
for i,v in next,game:GetService('StarterGui'):GetChildren() do
v:Clone().Parent = ReplicatedStorage.GuiBackup
end
if normal == false then
local theme = Library.getThemeColor()
for i,v in next,script.MenuGui:GetDescendants() do
if v:IsA("TextButton") and v.Name == 'Close' then
v.BackgroundColor3 = theme
end
end
end
if ((not maptest) and game.PlaceId ~= 14442395477) and
script.MenuGui:FindFirstChild("MapTest") then
script.MenuGui.MapTest:Destroy()
end
--[[if game.GameId ~= 4989130044 and script.MenuGui:FindFirstChild("Admin") then
script.MenuGui.Admin:Destroy()
end]]
script.MenuGui:Clone().Parent = ReplicatedStorage.GuiBackup
game:GetService('Players').PlayerAdded:Connect(function(player)
script.MenuGui:Clone().Parent = player:WaitForChild("PlayerGui")
local firstset = false
player.CharacterAdded:Connect(function(character)
if firstset == false then
firstset = true
delay(5,function()
UpdIngameStats:FireClient(player,Ingamestats)
end)
end
character:WaitForChild("Humanoid").Died:Connect(function()
if player == nil then
return
end
local humRtPt = character:FindFirstChild("HumanoidRootPart")
local MapSpawn = workspace.Multiplayer:FindFirstChild("Map") and
workspace.Multiplayer.Map:FindFirstChild("Spawn")
local inspawn = false
local canauto = false
if table.find(curPlaying,player) then
canauto = true
end
if MapSpawn ~= nil then
if humRtPt ~= nil then
local min = MapSpawn.Position - (MapSpawn.Size * 0.5)
local max = MapSpawn.Position + (MapSpawn.Size * 0.5)
if humRtPt.Position.X >= min.X and humRtPt.Position.X
<= max.X and humRtPt.Position.Z >= min.Z and humRtPt.Position.Z <= max.Z then
inspawn = true
end
end
end
for i = 1, #Waiting do
if Waiting[i] == player then
table.remove(Waiting, i)
break
end
end
delay(game.Players.RespawnTime, function()
player:LoadCharacter()
if canauto == true and not inspawn then
wait()
if table.find(Waiting, player) then
return
end
table.insert(Waiting, player)
if voting then

ReplicatedStorage.Remote.NewMapVote:FireClient(player, voteStats)
end
local humRtPt = player.Character and
player.Character:FindFirstChild("HumanoidRootPart")
if humRtPt then
humRtPt.CFrame =
game.Workspace.Lobby.WaitingRegion.CFrame --
game.Workspace.Lobby.WaitingArea.WaitTeleport.CFrame
end
--
player.Character:MoveTo(game.Workspace.Lobby.WaitingRegion.Position)
end
end)

print("Summary:", plrSumData[player.Name])

local function summary()


local totalXP = 0
local mapXP = 0
local addGameplayData = {
xpEarned = 0, --Total XP of all time
mapsPlayed = { 0, 0, 0, 0, 0, 0 }, -- Easy, Normal,
Hard, Insane, Crazy, Crazy+
mapsSurvived = { 0, 0, 0, 0, 0, 0 }, -- Easy, Normal,
Hard, Insane, Crazy, Crazy+
diedIngame = 0, --Player died in total
mapHighestStreak = 0,
mapBestTimes = {},
buttonsPressed = 0,
lostPagesCollected = {},
dailyChallengesCompleted = 0
}

local Streak = #plrSumData[player.Name]


for i, map in pairs(plrSumData[player.Name]) do
if #map > 1 then
for s = 2, #map do
if type(map[s][2]) == 'number' then
local addXP = map[s][2]
if map[s][3] ~= nil then
addXP = addXP * map[s][3]
end
mapXP = mapXP + addXP
end
end
end
local Dif = map.MapInfo.Difficulty;

if map.Survived ~= nil then


addGameplayData.mapsSurvived[Dif] += 1;

pcall(function()
local Track =
MainData[player.Name].plrData.gameplayStats

local canChange = false;

if Track.mapBestTimes[map.MapInfo.Name]
~= nil then
if map.Survived.Time <
Track.mapBestTimes[map.MapInfo.Name] then
canChange = true;
end
else
canChange = true;
end

if canChange then

Track.mapBestTimes[map.MapInfo.Name] = map.Survived.Time
end
end)
else
addGameplayData.diedIngame += 1;
end

addGameplayData.mapsPlayed[Dif] += 1
addGameplayData.buttonsPressed += map.Buttons.Pressed

totalXP = totalXP + mapXP


end
addGameplayData.xpEarned = totalXP

if MainData[player.Name].plrData.gameplayStats then

local tracker =
MainData[player.Name].plrData.gameplayStats

if Streak > tracker.mapHighestStreak then


tracker.mapHighestStreak = Streak
end

for i,v in pairs(addGameplayData) do


if i ~= "mapHighestStreak" then
if type(v) == 'number' then
tracker[i] = tracker[i] + v
elseif type(v) == 'table' then
if i ~= "mapBestTimes" and i ~=
"lostPagesCollected" then
for ii,vv in next, v do
tracker[i][ii] =
tracker[i][ii] + vv
end
else
for ii,vv in next, v do
tracker[i][ii] = vv
end
end
end
else
if type(v) == 'number' and tracker[i] < v
then
tracker[i] = v
end
end
end
end
Givexp(player, totalXP)
ShowSummary:FireClient(player,
FormatSummaryData(plrSumData[player.Name], true, totalXP))
--ShowSummary:FireClient(player, plrSumData[player.Name],
true, totalXP)
plrSumData[player.Name] = {}
plrBtnData[player.Name] = 0
plrGroupBtnData[player.Name] = 0
end

for o = 1, #curPlaying do
if curPlaying[o] == player then
table.remove(curPlaying, o)
UpdateCurPlaying()
if plrBtnData[player.Name] > 0 then
table.insert(plrSumData[player.Name]
[#plrSumData[player. Name]], {
"Button",
10,
plrBtnData[player.Name]
})
end
if plrGroupBtnData[player.Name] > 0 then
table.insert(plrSumData[player.Name]
[#plrSumData[player. Name]], {
"GroupButton",
20,
plrGroupBtnData[player.Name]
})
end

summary()
break
end
end
for o = 1, #Survivors do
if Survivors[o] == player then
table.remove(Survivors, o)
if plrBtnData[player.Name] > 0 then
table.insert(plrSumData[player.Name]
[#plrSumData[player. Name]], {
"Button",
10,
plrBtnData[player.Name]
})
end
if plrGroupBtnData[player.Name] > 0 then
table.insert(plrSumData[player.Name]
[#plrSumData[player. Name]], {
"GroupButton",
20,
plrGroupBtnData[player.Name]
})
end
summary()
break
end
end
end)
end)
end)

local function onCharacterRemoving(character)


local player = getPlayerFromCharacter(character)
if player == nil then
return
end
end
local NextMapFired = nil
local nmv = Instance.new("ObjectValue",script)
nmv.Name = "MapSelector"
local function str_escape(b)return b:gsub('%%','%%%%'):gsub('^%^','%%^'):gsub('%$
$','%%$'):gsub('%(','%%('):gsub('%)','%%)'):gsub('%.','%%.'):gsub('%[','%%
['):gsub('%]','%%]'):gsub('%*','%%*'):gsub('%+','%%+'):gsub('%-','%
%-'):gsub('%?','%%?')end
--local adms = require(script.Admins)
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
player.CharacterAppearanceLoaded:Connect(onCharacterLoaded)
player.CharacterRemoving:Connect(onCharacterRemoving)
plrSumData[player.Name] = {}
plrBtnData[player.Name] = 0
plrGroupBtnData[player.Name] = 0
--[[if table.find(adms,player.UserId) then
player.Chatted:Connect(function(msg,rec)
if msg:sub(1,11):lower() == "/overwrite " then
local tosearch = msg:sub(12,-1):lower()
nmv.Value = nil
for i,v in next,MapStorage:GetChildren() do
if v:FindFirstChild("Settings") and
v.Settings:FindFirstChild("MapName") then
if
string.find(v.Settings.MapName.Value:lower(),str_escape(tosearch)) then
nmv.Value = v
break
end
end
end
if nmv.Value ~= nil then
Alert:FireClient(player,"Selected Map: " ..
nmv.Value.Settings.MapName.Value)
else
Alert:FireClient(player,"Failed to search the map to
overwrite.")
end
NextMapFired(player,nmv)
end
end)
end--]]
PlrCaches[player.Name] = {}
local DSPD = DataStoreService:GetDataStore("PlayerData")
local success, data = pcall(function()
return DSPD:GetAsync(player.UserId..Datastring)
end)

if success and data then


--if data.plrData.options == nil then
-- data.plrData.options = Library.generateOptionsTab()
--end
if data.plrData.redeemed ~= nil then
data.plrData.usedCodes = {}
for code, v in pairs(data.plrData.redeemed) do
table.insert(data.plrData.usedCodes,code)
end
data.plrData.redeemed = nil
end
data.plrData = DataFormatting.checkData(data.plrData)
if maptest then
pcall(function()
if data.plrData.options.Main.preferFE2IO == nil then
data.plrData.options.Main.preferFE2IO = {
LayoutOrder = 2,
Name = "FE2IO Preferred",
Property = {
Value = true,
Type = "boolean"
}
}
end
end)
end
MainData[player.Name] = data
print("loaded "..player.Name.."'s data")
else
local newData = {plrData = DataFormatting.newTemplate()} --
table.clone(StarterData)
newData.plrData.options = Library.generateOptionsTab()
MainData[player.Name] = newData
end
player:SetAttribute("ServerIsReady", true)
end

Players.PlayerAdded:Connect(onPlayerAdded)
--PlayerAdded.Event:Connect(onPlayerAdded)
local function OnPlayerRemove(player)
for o = 1, #curPlaying do
if curPlaying[o] == player then
table.remove(curPlaying, o)
UpdateCurPlaying()
end
end
for o = 1, #Survivors do
if Survivors[o] == player then
table.remove(Survivors, o)
UpdateCurPlaying()
end
end
MainData[player.Name].plrData.stats.lastLogin = os.date("*t")
local DSPD = DataStoreService:GetDataStore("PlayerData")
local success, err = pcall(function()
--if maptest then
-- return
--end
DSPD:SetAsync(player.UserId..Datastring, MainData[player.Name])
end)

if success then
print("Saved "..player.Name.."'s data")
else
warn("Cant save "..player.Name.."'s data :" ..err)
end
end

Players.PlayerRemoving:Connect(OnPlayerRemove)

ReqPasskey.OnServerInvoke = onReqPasskeyFired
------------------------------------------------------------
--[[StarterData = {
plrData = {
Banned = false,
BanReason = "",
stats = {
level = 1,
xp = 0,
lastLogin = {},
rebirth = 0,
consecutiveLogins = 0,
coins = 2,
gems = 0,
},
equipped = {
main = 0,
Abilities = 0,
Auras = 0,
Buddies = 0,
Codes = 0,
Currency = 0,
Emotes = 0,
Gamepasses = 0,
InsaneLock = 0,
Skins = 0,
Tanks = 0,
},
inventory = {

},
usedCodes = { --redeemed = {

},
options = Library.generateOptionsTab(),
gameplayStats = DataFormatting.setupGameplayTracking(),
dailyChallenges =
require(game.ServerScriptService.Misc.SV_DailyChallenges.ChallengeModule).newChalle
nges(),
boughtStarterPack = nil,
saveVersion = 0
},
}]]

function checkItemOwnership(tabl, ID)


for _, check in pairs(tabl) do
if ID == check then
return true
end
end
end

local function onReqItemDataFired(player)


repeat
wait(0.1)
until MainData[player.Name] ~= nil
local MainPlr = MainData[player.Name]
local plrData = {}
for name, value in pairs(DataFormatting.newTemplate()) do
plrData[name] = MainPlr.plrData[name] or value --
MainData[player.Name]:Get(name)
end
local itemData = itemDataL
delay(1,function()
if voting == true then
ReplicatedStorage.Remote.NewMapVote:FireClient(player,voteStats)
end
end)
delay(1, function()
UpdIngameStats:FireClient(player, Ingamestats)
end)
return plrData, itemData
end

ReqItemDataOLD.OnServerInvoke = onReqItemDataFired

ReqItemData.OnServerEvent:Connect(function(player, key, getback)


if -PassKey ~= key then
return
end
repeat
wait(0.1)
until MainData[player.Name] ~= nil
local MainPlr = MainData[player.Name]
local plrData = {}
for name, value in pairs(DataFormatting.newTemplate()) do
plrData[name] = MainPlr.plrData[name] or value --
MainData[player.Name]:Get(name)
end
local itemData = itemDataL
if getback == true then
ReqItemData:FireClient(player, plrData, itemData)
end
end)
function DeEquipt(player, SID)
local descendants = NSF:GetDescendants()
for index, descendant in pairs(descendants) do
if descendant.Parent.Parent.Name == "Items" then--"Shop" then
if descendant.ID.Value == SID then
if descendant.Parent.Name == "Auras" then
local children = descendant:GetChildren()
for i, child in ipairs(children) do
if child.Name ~= "ID" then

MainData[player.Name].plrData.equipped.Auras = 0
if
player.Character.HumanoidRootPart:FindFirstChild(child.Name) then

player.Character.HumanoidRootPart:FindFirstChild(child.Name):Destroy()
end
UpdPlayerData:FireClient(player,
MainData[player.Name].plrData)
end
end
elseif descendant.Parent.Name == "Buddies" then
MainData[player.Name].plrData.equipped.Buddies = 0
if workspace.Buddies:FindFirstChild(player.Name ..
"_Buddy") then
workspace.Buddies:FindFirstChild(player.Name ..
"_Buddy"):Destroy()
end
UpdPlayerData:FireClient(player,
MainData[player.Name].plrData)
end
end
end
end
end

function GetitmTab(id)
for _, c in pairs(itemDataL) do
if c.ID == id then
return c
end
end
end

function Equipt(player, item, ovr)


--print("EQUIPT FIRED FOR:
"..player.name..":"..tostring(item)..":"..tostring(ovr))
--FIX MEEEEE
local itemdata = GetitmTab(item)
local itemobj = nil
if itemdata == nil then
return
end
if NSF:FindFirstChild(itemdata.catagory) then
if NSF[itemdata.catagory]:FindFirstChild(tostring(item)) then
itemobj = NSF[itemdata.catagory][tostring(item)]
end
end
if ovr ~= true then
if MainData[player.Name].plrData.equipped[itemdata.catagory] ~= item
then
if GetitmTab(item).currency == 0 then
print(MainData[player.Name].plrData.inventory[item])
if
checkItemOwnership(MainData[player.Name].plrData.inventory,item) == true then

elseif GetitmTab(item).notForSale == true then


return
elseif MainData[player.Name].plrData.stats.coins >=
GetitmTab(item).price then
MainData[player.Name].plrData.stats.coins =
MainData[player.Name].plrData.stats.coins - GetitmTab(item).price
else
return
end
elseif GetitmTab(item).currency == 1 then
if
checkItemOwnership(MainData[player.Name].plrData.inventory,item) == true then

elseif MainData[player.Name].plrData.stats.gems >=


GetitmTab(item).price then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems - GetitmTab(item).price
else
return
end
elseif GetitmTab(item).currency == 2 then
Alert:FireClient(player,"This is not available.")
return
--[[if
checkItemOwnership(MainData[player.Name].plrData.inventory,item.ID.Value) == true
then

elseif MainData[player.Name].plrData.stats.gems >=


GetitmTab(item.ID.Value).price then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems - GetitmTab(item.ID.Value).price
else
return
end]]
end
end
end
if itemdata.catagory == "Auras" then
if MainData[player.Name].plrData.equipped.Auras == item and ovr ~= true
then
local toremove = MainData[player.Name].plrData.equipped.Auras
MainData[player.Name].plrData.equipped.Auras = 0
if NSF.Auras:FindFirstChild(tostring(toremove)) then
local rf = NSF.Auras:FindFirstChild(tostring(toremove))
local r = rf:GetChildren()
for _,c in pairs(r) do
local cobj = player.Character:FindFirstChild(c.Name)
if cobj and c:IsA("Folder") then
for _,v in pairs(c:GetChildren()) do
local found = cobj:FindFirstChild(v.Name)
if found then
found:Destroy()
end
end
elseif cobj then
cobj:Destroy()
end
end
end
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
return
elseif MainData[player.Name].plrData.equipped.Auras ~= 0 and ovr ~=
true then
local toremove = MainData[player.Name].plrData.equipped.Auras
MainData[player.Name].plrData.equipped.Auras = 0
if NSF.Auras:FindFirstChild(tostring(toremove)) then
local rf = NSF.Auras:FindFirstChild(tostring(toremove))
local r = rf:GetChildren()
for _,c in pairs(r) do
local cobj = player.Character:FindFirstChild(c.Name)
if cobj and c:IsA("Folder") then
for _,v in pairs(c:GetChildren()) do
local found = cobj:FindFirstChild(v.Name)
if found then
found:Destroy()
end
end
elseif cobj then
cobj:Destroy()
end
end
end
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
end
if checkItemOwnership(MainData[player.Name].plrData.inventory, item) ~=
true then
table.insert(MainData[player.Name].plrData.inventory, item)
end
MainData[player.Name].plrData.equipped.Auras = item
if NSF.Auras:FindFirstChild(tostring(item)) then
local rf = NSF.Auras:FindFirstChild(tostring(item))
local r = rf:GetChildren()
for _,c in pairs(r) do
local cobj = player.Character:FindFirstChild(c.Name)
if cobj then
for _,v in pairs(c:GetChildren()) do
v:Clone().Parent = cobj
end
end
end
end
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
elseif itemdata.catagory == "Emotes" then
if MainData[player.Name].plrData.equipped.Emotes == item and ovr ~=
true then
player.Character.Animate.UpdEmote:FireClient(player, 0)
MainData[player.Name].plrData.equipped.Emotes = 0
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
if player.Character:FindFirstChild("Head") then
if player.Character.Head:FindFirstChild("Emote") then
player.Character.Head.Emote:Destroy()
end
end
return
elseif MainData[player.Name].plrData.equipped.Emotes ~= 0 and ovr ~=
true then
player.Character.Animate.UpdEmote:FireClient(player, 0)
if player.Character:FindFirstChild("Head") then
if player.Character.Head:FindFirstChild("Emote") then
player.Character.Head.Emote:Destroy()
end
end
end
if checkItemOwnership(MainData[player.Name].plrData.inventory, item) ~=
true then
table.insert(MainData[player.Name].plrData.inventory, item)
end
MainData[player.Name].plrData.equipped.Emotes = item
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
if itemobj:FindFirstChild("Sound") then
if player.Character:FindFirstChild("Head") then
if player.Character.Head:FindFirstChild("Emote") then
player.Character.Head.Emote:Destroy()
end
local newsound = Instance.new("Sound")
newsound.Name = "Emote"
newsound.Parent = player.Character:FindFirstChild("Head")
newsound.SoundId = itemobj.Sound.SoundId
newsound.Volume = 1
newsound.Pitch = itemobj.Sound.Pitch
end
else
if player.Character:FindFirstChild("Head") then
if player.Character.Head:FindFirstChild("Emote") then
player.Character.Head.Emote:Destroy()
end
end
end
player.Character.Animate.UpdEmote:FireClient(player, itemobj.Value)
--UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
elseif itemdata.catagory == "Skins" then
if MainData[player.Name].plrData.equipped.Skins == item and ovr ~= true
then
player:ClearCharacterAppearance()
for i,desc in pairs(player.Character:GetDescendants()) do
if desc:IsA("CharacterAppearance") or desc:IsA("Decal") and
(desc.Name == "face" or desc.Name == "Face") then
desc:Destroy()
end
end
MainData[player.Name].plrData.equipped.Skins = 0
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
local model =
game:GetService("Players"):GetCharacterAppearanceAsync(player.UserId)
local headmeshed = false
for _, child in pairs(model:GetChildren()) do
if child:IsA("Decal") and (child.Name == "face" or
child.Name == "Face") then
child.Parent =
player.Character:FindFirstChild("Head")
elseif child:IsA("CharacterMesh") then
child.Parent = player.Character
elseif child:FindFirstChildOfClass("CharacterMesh") then
for i,v in pairs(child:GetChildren()) do
v.Parent = player.Character
end
elseif child:IsA("DataModelMesh") then
local head = player.Character:FindFirstChild("Head")
if head then
local mesh =
head:FindFirstChildOfClass("DataModelMesh")
if mesh then
mesh:Destroy()
end
child:Clone().Parent = head
headmeshed = true
end
elseif child:IsA("Accoutrement") then
player.Character.Humanoid:AddAccessory(child)
elseif child:IsA("CharacterAppearance") then
player:LoadCharacterAppearance(child)
end
end
if headmeshed == false then
local head = player.Character:FindFirstChild("Head")
if head then
local mesh =
head:FindFirstChildOfClass("DataModelMesh")
if mesh and not mesh:IsA("SpecialMesh") then
mesh:Destroy()
local rmesh = Instance.new("SpecialMesh",head)
rmesh.Scale = Vector3.new(1,1,1)
rmesh.MeshType = Enum.MeshType.Head
end
end
end
--[[local Done = false
for item, value in
pairs(game.Players:GetCharacterAppearanceInfoAsync(player.UserId).assets) do
if value.assetType.name == "Face" then
local function makeface() local a =
Instance.new("Decal",player.Character.Head) a.Name = "face" a.Texture =
"rbxasset://textures/face.png" return a end
(player.Character.Head:FindFirstChild("face") or
player.Character.Head:FindFirstChild("Face") or makeface()).Texture =
"rbxassetid://"..tostring(value.id)
Done = true
break
end
end
if Done ~= true then
local function makeface() local a =
Instance.new("Decal",player.Character.Head) a.Name = "face" a.Texture =
"rbxasset://textures/face.png" return a end
(player.Character.Head:FindFirstChild("face") or
player.Character.Head:FindFirstChild("Face") or makeface()).Texture =
"rbxasset://textures/face.png"
end]]
return
elseif MainData[player.Name].plrData.equipped.Skins ~= 0 and ovr ~=
true then
player:ClearCharacterAppearance()
for i,desc in pairs(player.Character:GetDescendants()) do
if desc:IsA("CharacterAppearance") or desc:IsA("Decal") and
(desc.Name == "face" or desc.Name == "Face") then
desc:Destroy()
end
end
end
if checkItemOwnership(MainData[player.Name].plrData.inventory, item) ~=
true then
table.insert(MainData[player.Name].plrData.inventory, item)
end
MainData[player.Name].plrData.equipped.Skins = item
if ovr == true then
wait(0.5)
end
player:ClearCharacterAppearance()
for i,desc in pairs(player.Character:GetDescendants()) do
if desc:IsA("CharacterAppearance") or desc:IsA("Decal") and
(desc.Name == "face" or desc.Name == "Face") then
desc:Destroy()
end
end
wait(0.1)
local children = itemobj:GetChildren()
local headmeshed = false
for i, child in ipairs(children) do
if child:IsA("Decal") and (child.Name == "face" or child.Name ==
"Face") then
child:Clone().Parent =
player.Character:FindFirstChild("Head")
elseif child:IsA("CharacterMesh") then
child:Clone().Parent = player.Character
elseif child:IsA("DataModelMesh") then
local head = player.Character:FindFirstChild("Head")
if head then
local mesh =
head:FindFirstChildOfClass("DataModelMesh")
if mesh then
mesh:Destroy()
end
child:Clone().Parent = head
headmeshed = true
end
else
player:LoadCharacterAppearance(child:Clone())
end
end
if headmeshed == false then
local head = player.Character:FindFirstChild("Head")
if head then
local mesh = head:FindFirstChildOfClass("DataModelMesh")
if mesh and not mesh:IsA("SpecialMesh") then
mesh:Destroy()
local rmesh = Instance.new("SpecialMesh",head)
rmesh.Scale = Vector3.new(1,1,1)
rmesh.MeshType = Enum.MeshType.Head
end
end
end
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
elseif itemdata.catagory == "Tanks" then
if MainData[player.Name].plrData.equipped.Tanks == item and ovr ~= true
then
player.Character.Tank:Destroy()
MainData[player.Name].plrData.equipped.Tanks = 0
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
return
elseif MainData[player.Name].plrData.equipped.Tanks ~= 0 and ovr ~=
true then
player.Character.Tank:Destroy()
end
if checkItemOwnership(MainData[player.Name].plrData.inventory, item) ~=
true then
table.insert(MainData[player.Name].plrData.inventory, item)
end
MainData[player.Name].plrData.equipped.Tanks = item
local a = itemobj:Clone()
a.Name = "Tank"
local children = a.Center:GetChildren()
for i, child in pairs(a:GetChildren()) do
if child.Name ~= "Center" and child:IsA("BasePart") then
local b = Instance.new("ManualWeld")
b.Parent = a.Center
b.Part0 = a.Center
b.Part1 = child
b.C1 = (CFrame.new(b.Part1.CFrame.p-
b.Part0.CFrame.p)*(b.Part1.CFrame-b.Part1.CFrame.p)):Inverse()
end
end
local b = Instance.new("ManualWeld")
b.Part0 = player.Character.Torso
b.Part1 = a.Center
b.Parent = b.Part0
a.Name = "Tank"
a.Parent = player.Character
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)

elseif itemdata.catagory == "Buddies" then


if MainData[player.Name].plrData.equipped.Buddies == item and ovr ~=
true then
if workspace.Buddies:FindFirstChild(player.Name .. "_Buddy") then
workspace.Buddies:FindFirstChild(player.Name ..
"_Buddy"):Destroy()
end
MainData[player.Name].plrData.equipped.Buddies = 0
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
return
elseif MainData[player.Name].plrData.equipped.Buddies ~= 0 and ovr ~=
true then
if workspace.Buddies:FindFirstChild(player.Name .. "_Buddy") then
workspace.Buddies:FindFirstChild(player.Name ..
"_Buddy"):Destroy()
end
end
if checkItemOwnership(MainData[player.Name].plrData.inventory, item) ~=
true then
table.insert(MainData[player.Name].plrData.inventory, item)
end
MainData[player.Name].plrData.equipped.Buddies = item
if workspace.Buddies:FindFirstChild(player.Name .. "_Buddy") then
workspace.Buddies:FindFirstChild(player.Name ..
"_Buddy"):Destroy()
end
local a = itemobj:Clone()
a.Name = player.Name .. "_Buddy"
a.Parent = workspace.Buddies
a:WaitForChild("Follow"):WaitForChild("StartFollowing"):Fire(player)

UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
elseif itemdata.catagory == "Currency" then

--elseif itemdata.catagory == "Gamepasses" then


--elseif itemdata.catagory == "" then
end
end
--[[local newdatashop = SF:Clone()
newdatashop.Parent = game.ReplicatedStorage
newdatashop.Name = "Items"
for i,v in pairs(newdatashop:GetDescendants()) do
if v.Name == "ID" and v:IsA("NumberValue") and v.Parent.Parent.Parent ==
newdatashop then
v.Parent.Name = v.Value
if v.Parent.Parent.Name == "Tanks" then
if v.Parent:FindFirstChild("Tank") then
local thetank = v.Parent.Tank
thetank.Name = tostring(v.Value)
thetank.Parent = v.Parent.Parent
v.Parent:Destroy()
end
elseif v.Parent.Parent.Name == "Emotes" then
if v.Parent:FindFirstChild("Anim") then
local animval = v.Parent.Anim
animval.Name = tostring(v.Value)
animval.Parent = v.Parent.Parent
v.Parent:Destroy()
end
elseif v.Parent.Parent.Name == "Buddies" then
if v.Parent:FindFirstChild("Buddy") then
local thebud = v.Parent.Buddy
thebud.Name = tostring(v.Value)
thebud.Parent = v.Parent.Parent
v.Parent:Destroy()
end
end
end
end]]
local buxcatagory = {"Gamepasses","Currency"}
local function ConfirmItemFired(player, pass, SID)
if -PassKey ~= pass then
Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
return
end
local isbux = nil
local itemtab = GetitmTab(SID)
if table.find(buxcatagory,itemtab.catagory) then
isbux = true
end
if isbux then
if itemtab.catagory == "Currency" and itemtab.currency == 2 then

game:GetService("MarketplaceService"):PromptProductPurchase(player,itemtab.ID)
elseif itemtab.catagory == "Gamepasses" and itemtab.currency == 2 then

game:GetService("MarketplaceService"):PromptGamePassPurchase(player,itemtab.ID)
end
else
--[[local descendants = SF:GetDescendants()
for index, descendant in pairs(descendants) do
if descendant.Parent.Parent.Name == "Shop" then
if descendant.ID.Value == SID then
Equipt(player, descendant)
end
end
end]]
Equipt(player, SID)
end
return true
end

ConfirmItem.OnServerEvent:Connect(ConfirmItemFired)
------------------------------------------------------------
local MarketplaceService = game:GetService("MarketplaceService")
CheckGamepassOwnership = function(player)
if PlrCaches[player.Name].OwnedGamepasses ~= nil then
return PlrCaches[player.Name].OwnedGamepasses
end
local owneds = {}
for i,v in pairs(itemDataL) do
if v and v.catagory == "Gamepasses" and v.ID then
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, v.ID)
then
table.insert(owneds, v.ID)
end
end
end
PlrCaches[player.Name].OwnedGamepasses = owneds
return owneds
end
ReplicatedStorage.Remote.CheckGamepassOwnership.OnServerInvoke =
CheckGamepassOwnership
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player,id,suc)
if suc == true and GetitmTab(id) then
ReplicatedStorage.Remote.UpdatedGamepassOwnership:FireClient(player,
{id})
end
end)
------------------------------------------------------------
local UpdOptions = ReplicatedStorage.Remote.UpdOptions
UpdOptions.OnServerEvent:Connect(function(player, option, key, isKey)
local MainPlr = MainData[player.Name]
local optionData = MainPlr.plrData.options
if isKey == 'Keybinds' then
if optionData.Keybinds[option] then
optionData.Keybinds[option].KeyString = key
end
else
if optionData['Main'] and optionData['Main'][option] then
local optionType = optionData['Main'][option].Property.Type
local oldValue = optionData['Main'][option].Property.Value
if optionType == 'boolean' then
optionData['Main'][option].Property.Value = not oldValue
elseif optionType == 'cycle' then
if oldValue >= #optionData['Main'][option].Property.Cycles
then
optionData['Main'][option].Property.Value = 1
else
optionData['Main'][option].Property.Value = oldValue
+ 1
end
end
end
end
UpdOptions:FireClient(player, MainPlr.plrData.options)
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
end)
------------------------------------------------------------
local function ReqVIPStatusFired(player, pass)
if -PassKey ~= pass then
Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
return
end
return false
end

ReqVIPStatus.OnServerInvoke = ReqVIPStatusFired
--[[--------------------------------------------------------
local function ReqUserMapListFired(player)
return true
end

ReqUserMapList.OnServerInvoke = ReqUserMapListFired
------------------------------------------------------------
local function ReqTestMapFired(player)
return true
end

ReqTestMap.OnServerInvoke = ReqTestMapFired
--]]--------------------------------------------------------
local function ForceMapEventFired(player,key,ev)
if -PassKey ~= key then
Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
return
end
forceevent = ev
--print("[TEST]: "..player.Name.." has forced map event to "..(ev or '*not
forced*'))
MapDebug:FireAllClients("Server: "..player.Name.." has forced map event to
"..(ev or '*not forced*'),BrickColor.new("White").Color)
end

ReplicatedStorage.Remote.TEST.ForceMapEvent.OnServerEvent:Connect(ForceMapEventFire
d)
------------------------------------------------------------
local function ReqAirToggleFired(player,key)
if -PassKey ~= key then
Alert:FireClient(player,"Anti-Exploit was triggered. Reporting to
moderator...")
return
end
game.ReplicatedStorage.Remote.TEST.AirToggle:FireClient(player)
end

ReqAirToggle.OnServerEvent:Connect(ReqAirToggleFired)
------------------------------------------------------------
local function ReqMapWhitelistFired(player)
return true
end

--ReqMapWhitelist.OnServerInvoke = ReqMapWhitelistFired
------------------------------------------------------------
local TeleportService = game:GetService("TeleportService")
ReqTele.OnServerEvent:Connect(function(player,id,uid)
Alert:FireClient(player,"Setting up teleport, Please wait...")
if id then
local success, errorMessage = pcall(function()
TeleportService:Teleport(id,player)
end)
if success then
else
Alert:FireClient(player,"Teleport failed, try again later.")
end
elseif uid then
local currentInstance, _, placeId, jobId
local success, errorMessage = pcall(function()
-- followId is the user ID of the player that you want to
retrieve the place and job ID for
currentInstance, _, placeId, jobId =
TeleportService:GetPlayerPlaceInstanceAsync(uid)
end)
if success then
-- Teleport player
local success, errorMessage = pcall(function()
TeleportService:TeleportToPlaceInstance(placeId, jobId,
player)
end)
if success then
else
Alert:FireClient(player,"Teleport failed, try again
later.")
end
else
Alert:FireClient(player,"Teleport failed, try again later.")
end
else
Alert:FireClient(player,"Teleport failed, try again later.")
end
end)
------------------------------------------------------------
--local rescuing = {}
local function
SurvivedFired(player,localplayer,key,air,exitRegion,exitRegPos,suvtime)
if -PassKey ~= key then
Alert:FireClient(player,"Illegally fired remote.")
return false
end
if player ~= localplayer then
Alert:FireClient(player,"Illegal player.")
return false
end
if air < 0 then
Alert:FireClient(player,"Illegal air value.")
return false
end
if exitRegion.Name ~= "ExitRegion" then
Alert:FireClient(player,"Illegal exitregion.")
return false
end
--[[if (not maptest) or exitRegion.Position ~= exitRegPos then
Alert:FireClient(player,"Illegal position.")
return false
end]]
local escapepos = #Survivors+1
table.insert(Survivors, player)
local Map = workspace.Multiplayer:WaitForChild("Map")
local difval = Map.Settings:FindFirstChild("Difficulty") and
Map.Settings.Difficulty.Value or Map.Settings:GetAttribute("Difficulty")
local diftext = tabDif[difval]
if diftext == nil then
diftext = "Unknown"
end
local difxp = SumDifVal[difval]
if difxp == nil then
difxp = 10
end
if MapInitModule.isRescuing(player) then
local togive = 1
if CurDif >= 3 then
togive = 2
end
Alert:FireClient(player,"✅ Rescue Complete! +"..togive.." Gem" ..
(togive == 1 and '' or "s"),Color3.fromRGB(241, 219, 128),nil,'event')
Sound:FireClient(player,983016958,0.5,1.35)
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems + togive
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
RescueTrigger:FireClient(player,nil,true)
plrSumData[player.Name][#plrSumData[player.Name]].Rescue = {
Reward = togive
}
end
--Alert:FireClient(player, "You Survived!", Color3.new(0, 1, 0))
Alert:FireClient(player,'Escaped ' ..
tostring(Map.Settings:FindFirstChild("MapName") and Map.Settings.MapName.Value or
Map.Settings:GetAttribute("MapName")) ..' (#' .. escapepos .. '): ' .. difxp .. '
XP', Color3.new(0.945098, 0.858824, 0.501961))
table.insert(plrSumData[player.Name][#plrSumData[player. Name]], {
"Button",
10,
plrBtnData[player.Name]
})
table.insert(plrSumData[player.Name][#plrSumData[player. Name]], {
"GroupButton",
20,
plrGroupBtnData[player.Name]
})
plrSumData[player.Name][#plrSumData[player.Name]].Buttons.Pressed =
plrBtnData[player.Name] + plrGroupBtnData[player.Name]
plrBtnData[player.Name] = 0
plrGroupBtnData[player.Name] = 0
table.insert(plrSumData[player.Name][#plrSumData[player.Name]], {
"Survived "..diftext,
difxp
})
if PAS == 1 then
table.insert(plrSumData[player.Name][#plrSumData[player.Name]], {
"Solo Survival",
40
})
end
plrSumData[player.Name][#plrSumData[player.Name]].Survived = {
Position = escapepos,
AllPlayers = PAS,
Time = suvtime
}
plrSumData[player.Name][#plrSumData[player.Name]].Difficulty = difval
for i = 1, #curPlaying do
if curPlaying[i] == player then
table.remove(curPlaying, i)
end
end
if player.Character:FindFirstChild("PlrInfo") then

player.Character.PlrInfo.Update.ShowInfo:Fire(player,MainData[player.Name].plrData,
false)
end
return true
end

Survived.OnServerInvoke = SurvivedFired
------------------------------------------------------------
game.Workspace.Multiplayer.PlayingBGM.BGMTime.OnServerInvoke = function(player)
if start ~= nil then
local gottime = tick() - start
if workspace.Multiplayer:FindFirstChild("Map") then
if workspace.Multiplayer.Map:FindFirstChild("Settings") then
if
workspace.Multiplayer.Map.Settings:FindFirstChild("DelayBGM") then
if workspace.Multiplayer.Map.Settings.DelayBGM.Value
== true then
gottime = gottime + 1
end
elseif
workspace.Multiplayer.Map.Settings:GetAttribute("DelayBGM") == true then
gottime = gottime + 1
end
end
end
return gottime
else
return 0
end
end
------------------------------------------------------------
local nextmap = nil
local mapIDs = {}

local function ReqLoadedMapsFired(player,unloaded)


--[[
if workspace.Multiplayer:FindFirstChild("Map") ~= nil then
return {
workspace.Multiplayer.Map.Settings
}
else
return {

}
end]]
local loadedmaps = {}
if unloaded == true then
for i,v in pairs(game.ServerStorage.UnloadedMaps:GetChildren()) do
if v:FindFirstChild("Settings") then
local settingss = {}
settingss.MapName = v.Settings:FindFirstChild("MapName")
and v.Settings.MapName.Value or v.Settings:GetAttribute("MapName") or ''
settingss.Difficulty =
v.Settings:FindFirstChild("Difficulty") and v.Settings.Difficulty.Value or
v.Settings:GetAttribute("Difficulty") or ''
settingss.MapImage = v.Settings:FindFirstChild("MapImage")
and v.Settings.MapImage.Value or v.Settings:GetAttribute("MapImage") or 0
settingss.Creator = v.Settings:FindFirstChild("Creator")
and v.Settings.Creator.Value or v.Settings:GetAttribute("Creator") or ''
settingss.specialMapName = nil
settingss.specialMapColor = nil
settingss.specialMap =
(v.Settings:FindFirstChild("Highlight") and v.Settings.Highlight.Value) or
v.Settings:GetAttribute("Highlight") or (v.Settings:FindFirstChild("Seasonal") and
v.Settings.Seasonal.Value) or v.Settings:GetAttribute("Seasonal") or false

local SpecialMapsVars = {
"Highlight",
"Seasonal"
}

local SpecialMaps = {
"Featured Map",
"Seasonal Map"
}

local SpecialMapsColors = {
Color3.fromRGB(85, 170, 127),
Color3.fromRGB(166, 231, 255)
}

if settingss.specialMap then
for k, u in next, SpecialMapsVars do
if (v.Settings:FindFirstChild(u) and
v.Settings[u].Value) or v.Settings:GetAttribute(u) then
settingss.specialMapName = SpecialMaps[k]
settingss.specialMapColor =
SpecialMapsColors[k]
end
end
end

if mapIDs[v] == nil then


local ob = Instance.new("ObjectValue")
ob.Parent = game.ReplicatedStorage.TESTClientStorage
ob.Name = v.Name
ob.Value = v
mapIDs[v] = ob
settingss.Instance = ob
else
settingss.Instance = mapIDs[v]
end
settingss.Loaded = false
settingss.NextMap = false
table.insert(loadedmaps,tonumber(#loadedmaps+1),settingss)
end
end
else
for i,v in pairs(MapStorage:GetChildren()) do
if v:FindFirstChild("Settings") then
local settingss = {}
settingss.MapName = v.Settings:FindFirstChild("MapName")
and v.Settings.MapName.Value or v.Settings:GetAttribute("MapName") or ''
settingss.Difficulty =
v.Settings:FindFirstChild("Difficulty") and v.Settings.Difficulty.Value or
v.Settings:GetAttribute("Difficulty") or ''
settingss.MapImage = v.Settings:FindFirstChild("MapImage")
and v.Settings.MapImage.Value or v.Settings:GetAttribute("MapImage") or 0
settingss.Creator = v.Settings:FindFirstChild("Creator")
and v.Settings.Creator.Value or v.Settings:GetAttribute("Creator") or ''
settingss.specialMapName = nil
settingss.specialMapColor = nil
settingss.specialMap =
(v.Settings:FindFirstChild("Highlight") and v.Settings.Highlight.Value) or
v.Settings:GetAttribute("Highlight") or (v.Settings:FindFirstChild("Seasonal") and
v.Settings.Seasonal.Value) or v.Settings:GetAttribute("Seasonal") or false

local SpecialMapsVars = {
"Highlight",
"Seasonal"
}

local SpecialMaps = {
"Featured Map",
"Seasonal Map"
}

local SpecialMapsColors = {
Color3.fromRGB(85, 170, 127),
Color3.fromRGB(166, 231, 255)
}

if settingss.specialMap then
for k, u in next, SpecialMapsVars do
if (v.Settings:FindFirstChild(u) and
v.Settings[u].Value) or v.Settings:GetAttribute(u) then
settingss.specialMapName = SpecialMaps[k]
settingss.specialMapColor =
SpecialMapsColors[k]
end
end
end

if mapIDs[v] == nil then


local ob = Instance.new("ObjectValue")
ob.Parent = game.ReplicatedStorage.TESTClientStorage
ob.Name = v.Name
ob.Value = v
mapIDs[v] = ob
settingss.Instance = ob
else
settingss.Instance = mapIDs[v]
end
settingss.Loaded = true
if nextmap == v then
settingss.NextMap = true
else
settingss.NextMap = false
end
table.insert(loadedmaps,tonumber(#loadedmaps+1),settingss)
end
end
end
return loadedmaps
end
local function UpdMapListPart(maps)
if type(maps) ~= 'table' then
maps = {maps}
end
local loadedmaps = {}
for i,v in pairs(maps) do
if v:FindFirstChild("Settings") then
local settingss = {}
if v:IsDescendantOf(MapStorage) == false and
v:IsDescendantOf(game.ServerStorage.UnloadedMaps) == false then
if mapIDs[v] ~= nil then
settingss.Instance = mapIDs[v]
settingss.Remove = true
end
else
settingss.MapName = v.Settings:FindFirstChild("MapName")
and v.Settings.MapName.Value or v.Settings:GetAttribute("MapName")
settingss.MapImage = v.Settings:FindFirstChild("MapImage")
and v.Settings.MapImage.Value or v.Settings:GetAttribute("MapImage")
settingss.Difficulty =
v.Settings:FindFirstChild("Difficulty") and v.Settings.Difficulty.Value or
v.Settings:GetAttribute("Difficulty")
settingss.Creator = v.Settings:FindFirstChild("Creator")
and v.Settings.Creator.Value or v.Settings:GetAttribute("Creator")
settingss.specialMapName = nil
settingss.specialMapColor = nil
settingss.specialMap =
(v.Settings:FindFirstChild("Highlight") and v.Settings.Highlight.Value) or
v.Settings:GetAttribute("Highlight") or (v.Settings:FindFirstChild("Seasonal") and
v.Settings.Seasonal.Value) or v.Settings:GetAttribute("Seasonal") or false

local SpecialMapsVars = {
"Highlight",
"Seasonal"
}

local SpecialMaps = {
"Featured Map",
"Seasonal Map"
}

local SpecialMapsColors = {
Color3.fromRGB(85, 170, 127),
Color3.fromRGB(166, 231, 255)
}

if settingss.specialMap then
for k, u in next, SpecialMapsVars do
if (v.Settings:FindFirstChild(u) and
v.Settings[u].Value) or v.Settings:GetAttribute(u) then
settingss.specialMapName = SpecialMaps[k]
settingss.specialMapColor =
SpecialMapsColors[k]
end
end
end

if mapIDs[v] == nil then


local ob = Instance.new("ObjectValue")
ob.Parent = game.ReplicatedStorage.TESTClientStorage
ob.Name = v.Name
ob.Value = v
mapIDs[v] = ob
settingss.Instance = ob
else
settingss.Instance = mapIDs[v]
end
settingss.Loaded = v:IsDescendantOf(MapStorage)
if nextmap == v then
settingss.NextMap = true
else
settingss.NextMap = false
end
end
table.insert(loadedmaps,tonumber(#loadedmaps+1),settingss)
end
end
ReplicatedStorage.Remote.TEST.UpdMapListPart:FireAllClients(loadedmaps)
end
function countParts(map)
local counts = 0
for i,v in next,map:GetDescendants() do
if v:IsA("BasePart") then
counts = counts + 1
end
end
return counts
end
local function RefreshMaps(noUpdAll)
--Setup Maps--
Maps0 = {}
Maps1 = {}
Maps2 = {}
Maps3 = {}
Maps4 = {}
Maps5 = {}
local children = MapStorage:GetChildren()
for i, child in ipairs(children) do
if child and child:FindFirstChild("Settings") then
--task.spawn(addMapVoteInfo,child)
if child.Settings:FindFirstChild("Difficulty") then
local diff =
math.clamp(tonumber(child.Settings.Difficulty.Value) or 6,1,6)
local mapt = diff == 1 and Maps0 or (diff == 2 and Maps1 or
(diff == 3 and Maps2 or (diff == 4 and Maps3 or (diff == 5 and Maps4 or diff == 6
and Maps5 or Maps5))))
table.insert(mapt, child)
elseif child.Settings:FindFirstChild("Intensity") then
local diff =
math.clamp(tonumber(child.Settings.Intensity.Value) or 6,1,6)
local mapt = diff == 1 and Maps0 or (diff == 2 and Maps1 or
(diff == 3 and Maps2 or (diff == 4 and Maps3 or (diff == 5 and Maps4 or diff == 6
and Maps5 or Maps5))))
table.insert(mapt, child)
elseif child.Settings:GetAttribute("Difficulty") or
child.Settings:GetAttribute("Intensity") then
local diff =
math.clamp(tonumber(child.Settings:GetAttribute("Difficulty")) or
tonumber(child.Settings:GetAttribute("Intensity")) or 6,1,6)
local mapt = diff == 1 and Maps0 or (diff == 2 and Maps1 or
(diff == 3 and Maps2 or (diff == 4 and Maps3 or (diff == 5 and Maps4 or diff == 6
and Maps5 or Maps5))))
table.insert(mapt, child)
end
if (not child.Settings:FindFirstChild("Creator")) and
type(child.Settings:GetAttribute("Creator")) ~= 'string' then
child.Settings:SetAttribute("Creator", '')
end
if type(child.Settings:GetAttribute("Creator")) ~= 'string' then
child.Settings:SetAttribute("Creator",
child.Settings.Creator.Value)
end
if not child.Settings:GetAttribute("AssetCount") then
child.Settings:SetAttribute("AssetCount", 0)
delay(0, function()
local store = child
child.Settings:SetAttribute("AssetCount",
countParts(store))
end)
end
else
if child then
game:GetService("TestService"):Error("Missing 'Settings'
Folder in '" .. child.Name .. "'")
child:Destroy()
else
game:GetService("TestService"):Error("Crazy error has
occured, loaded map is not cached / unable to load with lua.")
end
end
end
Maps = {
[1] = Maps0,
[2] = Maps1,
[3] = Maps2,
[4] = Maps3,
[5] = Maps4,
[6] = Maps5,
}
---
if noUpdAll ~= true then
--game.ReplicatedStorage.TESTClientStorage:ClearAllChildren()
UpdLoadedMaps:FireAllClients(ReqLoadedMapsFired(nil))
UpdLoadedMaps:FireAllClients(ReqLoadedMapsFired(nil,true))
end
end

ReqLoadedMaps.OnServerInvoke = ReqLoadedMapsFired

MapStorage.ChildAdded:Connect(function(c)
RefreshMaps(true)
UpdMapListPart(c)
end)
MapStorage.ChildRemoved:Connect(function(c)
--pcall(removeMapVoteInfo, c)
RefreshMaps(true)
UpdMapListPart(c)
end)
RefreshMaps()
--------------------------------Vote-
ReplicatedStorage.Remote.UpdMapVote.OnServerEvent:Connect(function(player, key,
mapID, cost)
if -PassKey ~= key then
Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
return
end
local votedMap = nil
for i,v in next,voteStats.mapData do
if v.ID == mapID then
votedMap = v
break
end
end
if votedMap == nil then return end
if voteStats.pVotes[tostring(player.UserId)] == nil then
voteStats.pVotes[tostring(player.UserId)] = {
mapID = mapID,
voteCount = 0,
votes = 0
}
end
local passes = CheckGamepassOwnership(player)
local allMapsAccess = passes and (table.find(passes, 14122753) ~= nil) or
false --change to real id: 14112023
local pVote = voteStats.pVotes[tostring(player.UserId)]
local actualCost = votedMap.locked == true and (allMapsAccess and 0 or
(votedMap.unlockCost or (pVote.voteCount == 0 and 0 or ((votedMap.extraVoteCost or
0) + (pVote.voteCount - 1) * 10)))) or (pVote.voteCount == 0 and 0 or
((votedMap.extraVoteCost or 0) + (pVote.voteCount - 1) * 10))
if cost == actualCost then
if MainData[player.Name].plrData.stats.coins >= actualCost then
MainData[player.Name].plrData.stats.coins =
MainData[player.Name].plrData.stats.coins - actualCost
votedMap.locked = false
pVote.votes = pVote.votes + 1
pVote.voteCount = pVote.votes * (allMapsAccess and (maptest and 4
or 2) or 1)
ReplicatedStorage.Remote.UpdMapVote:FireAllClients(voteStats)
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
votedFirst = true
end
else
Alert:FireClient(player, "Failed to confirm vote cost")
end
end)
--Adds-------------------------------
local function RemoveLoadedMapFired(player,ins,load)
if voting == true then
MapDebug:FireClient(player,"Map is voting! Cancelled map remove.",
Color3.new(1,0,0))
return
end
if game.GameId ~= 4989130044 and maptest then
if #MapStorage:GetChildren() <= 1 then
pcall(function()
MapDebug:FireClient(player,"There must be at least one
map.",Color3.new(1,0,0))
end)
return
end
pcall(function()
MapDebug:FireAllClients(player.Name.." has removed the map: "..(
ins.Value.Settings:FindFirstChild("MapName")
and ins.Value.Settings.MapName.Value
or ins.Value.Settings:GetAttribute("MapName")
),BrickColor.new("White").Color)
end)
if nextmap == ins.Value then
nextmap = nil
pcall(function()
MapDebug:FireAllClients("Server: Next map is not overridden
now.")
end)
end
ins.Value:Destroy()
return
end
if load == true then
ins.Value.Parent = MapStorage
pcall(function()
MapDebug:FireAllClients("Server: "..player.Name.." has loaded the
map: "..(
ins.Value.Settings:FindFirstChild("MapName")
and ins.Value.Settings.MapName.Value
or ins.Value.Settings:GetAttribute("MapName")
),BrickColor.new("White").Color)
end)
else
ins.Value.Parent = game.ServerStorage.UnloadedMaps
pcall(function()
MapDebug:FireAllClients("Server: "..player.Name.." has unloaded
the map: "..(
ins.Value.Settings:FindFirstChild("MapName")
and ins.Value.Settings.MapName.Value
or ins.Value.Settings:GetAttribute("MapName")
),BrickColor.new("White").Color)
end)
end
end
RemoveLoadedMap.OnServerEvent:Connect(RemoveLoadedMapFired)

local function NextMapFired(player,ins)


--MapDebug:FireClient(player, "[WARNING]: Next Map feature is deprecated,
this feature may be deleted in the future for map testing.", Color3.new(1,0.5,0))
if ins ~= nil and ins.Value ~= nil then
nextmap = ins.Value
pcall(function()
MapDebug:FireAllClients("Server: "..player.Name.." has overridden
the next map to "..(
ins.Value.Settings:FindFirstChild("MapName")
and ins.Value.Settings.MapName.Value
or ins.Value.Settings:GetAttribute("MapName")
),BrickColor.new("White").Color)
end)
UpdMapListPart(ins.Value)
else
local oldnext = nextmap
nextmap = nil
UpdMapListPart(oldnext)
end
RefreshMaps(true)
end
game.ReplicatedStorage.Remote.TEST:WaitForChild("NextMap").OnServerEvent:Connect(Ne
xtMapFired)
local msgcols = {
[Enum.MessageType.MessageOutput] = BrickColor.new("White").Color;
[Enum.MessageType.MessageInfo] = BrickColor.new("Bright blue").Color;
[Enum.MessageType.MessageWarning] = BrickColor.new("Bright yellow").Color;
[Enum.MessageType.MessageError] = BrickColor.new("Bright red").Color;
}
--game:GetService("LogService").MessageOut:Connect(function(msg,msgtype)
-- if msgtype == nil then msgtype = Enum.MessageType.MessageOutput end
-- MapDebug:FireAllClients(msg,msgcols[msgtype])
--end)
game:GetService("ScriptContext").Error:Connect(function(msg,trace,scr)
if scr == script or scr:IsDescendantOf(workspace.Multiplayer) then
MapDebug:FireAllClients(msg,msgcols[Enum.MessageType.MessageError])
end
end)
--------------Added/Edited------------
-----------------------------------------------------------
local function RemoveWaitingFired(player,key)
--if -PassKey ~= key then
-- Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
-- return
--end
for i = 1, #Waiting do
if Waiting[i] == player then
table.remove(Waiting, i)
end
end
local humRtPt = player.Character and
player.Character:FindFirstChild("HumanoidRootPart")
if humRtPt then
humRtPt.CFrame = game.Workspace.Lobby.WaitingArea.ExitTeleport.CFrame
end
if voting then
ReplicatedStorage.Remote.UpdMapVote:FireClient(player)
end
UpdateGameState:FireClient(player,nil)
Sound:FireClient(player,34320976, 1, 1.1)
end
local function AddedWaitingFired(player,key)
--if -PassKey ~= key then
-- Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
-- return
--end
if table.find(Waiting, player) then
return
end
table.insert(Waiting, player)
--local humRtPt = player.Character and
player.Character:FindFirstChild("HumanoidRootPart")
--if humRtPt then
-- humRtPt.CFrame = game.Workspace.Lobby.WaitingArea.WaitTeleport.CFrame
--end
Alert:FireClient(player,"You will join the next round")
if voting then
ReplicatedStorage.Remote.NewMapVote:FireClient(player, voteStats)
end
end

AddedWaiting.OnServerEvent:Connect(AddedWaitingFired)
-----------------------------------------------------------

RemoveWaiting.OnServerEvent:Connect(RemoveWaitingFired)
-----------------------------------------------------------
local function ReqRebirthFired(player)
if MainData[player.Name].plrData.stats.level >= 100 and
MainData[player.Name].plrData.stats.xp >= 12000 and
MainData[player.Name].plrData.stats.rebirth < 10 then
LvlUp:FireClient(player, 5)
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems + 5
MainData[player.Name].plrData.stats.xp = 0
MainData[player.Name].plrData.stats.level = 1
MainData[player.Name].plrData.stats.rebirth =
MainData[player.Name].plrData.stats.rebirth + 1
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
end
end

ReqRebirth.OnServerEvent:Connect(ReqRebirthFired)
------------------------------------------------------------
function Givexp(player, xp)
local DateVal = os.date("*t")
local ATLeaderStore =
DataStoreService:GetOrderedDataStore(LBString.."ATLeaderStore")
local CMLeaderStore =
DataStoreService:GetOrderedDataStore(LBString.."CMLeaderStore"..MonthNames[DateVal.
month]..DateVal.year)
MainData[player.Name].plrData.stats.xp =
MainData[player.Name].plrData.stats.xp + xp
MainData[player.Name].plrData.stats.coins =
MainData[player.Name].plrData.stats.coins + Library.getXPCoinAward(xp)
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems + Library.getXPGemAward(xp)
if MainData[player.Name].plrData.stats.xp >=
Library.calcLevelXP(MainData[player.Name].plrData.stats.level) then
repeat
MainData[player.Name].plrData.stats.xp =
MainData[player.Name].plrData.stats.xp -
Library.calcLevelXP(MainData[player.Name].plrData.stats.level)
MainData[player.Name].plrData.stats.level =
MainData[player.Name].plrData.stats.level + 1
until MainData[player.Name].plrData.stats.xp <
Library.calcLevelXP(MainData[player.Name].plrData.stats.level)
LvlUp:FireClient(player, 5)
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems + 5
if MainData[player.Name].plrData.stats.level >= 100 then
MainData[player.Name].plrData.stats.xp = Library.calcLevelXP(100)
end
end
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
local success, pages = pcall(function()
return ATLeaderStore:GetAsync(player.Name)
end)
if success then
if pages then
local success = pcall(function()
--[[if game.GameId ~= 15016276688 and maptest then
return
end]]
ATLeaderStore:IncrementAsync(player.Name,xp)
end)
else
local success = pcall(function()
--[[if game.GameId ~= 15016276688 and maptest then
return
end]]
ATLeaderStore:SetAsync(player.Name,xp)
end)
end
else
warn("Error getting Cur month leader store for "..player.Name)
end
local success, pages = pcall(function()
return CMLeaderStore:GetAsync(player.Name)
end)
if success then
if pages then
local success = pcall(function()
--[[if game.GameId ~= 15016276688 and maptest then
return
end]]
CMLeaderStore:IncrementAsync(player.Name,xp)
end)
else
local success = pcall(function()
--[[if game.GameId ~= 15016276688 and maptest then
return
end]]
CMLeaderStore:SetAsync(player.Name,xp)
end)
end
else
warn("Error getting All time leader store for "..player.Name)
end
end

game.ServerStorage.Bindables.AwardTrophy.Event:Connect(function(player, trophyId,
rank)
local pData = MainData[player.Name]
if pData then
--Check if already own trophy
local ownsItem
for _, c in pairs(pData.plrData.inventory) do
if c == trophyId then
ownsItem = true
break
end
end

if not ownsItem then


table.insert(pData.plrData.inventory, trophyId)
Notify:FireClient(player, "Congratulations, you ranked among the
top 3 on the Monthly XP Leaderboard! You have been awarded an exclusive trophy
tank. Enjoy!", "Congratulations! Rank #"..rank)
end
end
end)
------------------------------------------------------------
--[[local function BuyDifLockFired(player, mode)
if LockedCurDif > 0 then
Alert:FireClient(player, "Lift already locked!")
return
end
if mode == 1 then
if MainData[player.Name].plrData.stats.gems >= 10 then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems - 10
Sound:FireAllClients(1044088048, 5)
LockedCurDif = 3
LockedCurDifLeft = 3
lockcounted = false

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Difficulty.Size =
UDim2.new(0.83, 0, 1, 0)

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Arrow.ImageColor3 =
difColors[LockedCurDif + 1]

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Amount.Text =
LockedCurDifLeft
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
Alert:FireAllClients(player.Name.." has locked the lift to
Insane!", Color3.fromRGB(170, 85, 255), false, false)
UpdIngameStatsFunc()
else
Alert:FireClient(player, "You don't have enough Gems!")
end
elseif mode == 2 then
if MainData[player.Name].plrData.stats.gems >= 25 then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems - 25
Sound:FireAllClients(1044088048, 5)
LockedCurDif = 4
LockedCurDifLeft = 1
lockcounted = false

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Difficulty.Size =
UDim2.new(0.83, 0, 1, 0)

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Arrow.ImageColor3 =
difColors[LockedCurDif + 1]
workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Amount.Text =
LockedCurDifLeft
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
Alert:FireAllClients(player.Name.." has locked the lift to
Crazy!", Color3.fromRGB(215, 131, 59), false, false)
UpdIngameStatsFunc()
else
Alert:FireClient(player, "You don't have enough Gems!")
end
elseif mode == 3 then
if MainData[player.Name].plrData.stats.gems >= 50 then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems - 50
Sound:FireAllClients(1044088048, 5)
LockedCurDif = 5
LockedCurDifLeft = 3
lockcounted = false

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Difficulty.Size =
UDim2.new(0.83, 0, 1, 0)

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Arrow.ImageColor3 =
difColors[LockedCurDif + 1]

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Amount.Text =
LockedCurDifLeft
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
Alert:FireAllClients(player.Name.." has locked the lift to
CRAZY+!", Color3.fromRGB(211, 84, 0), false, false)
UpdIngameStatsFunc()
else
Alert:FireClient(player, "You don't have enough Gems!")
end
end
end]]
local function BuyDifLockFired(player, mode)
if LockedCurDif > 0 then
Alert:FireClient(player, "Lift already locked!")
return
end
Alert:FireClient(player, "Pro Lock is temporality disabled for Intensity
Update.", Color3.new(1,.5))
end
BuyDifLock.OnServerEvent:Connect(BuyDifLockFired)
------------------------------------------------------------
local boostCosts = (not chaos) and {
5, -- 1. +0.5
9, -- 2. final: +1.0
16, -- 3. final: +1.5
28, -- 4. final: +2.0
49, -- 5. final: +2.5
98, -- 6. final: +3.0
--[[196, --test
392, --test
784, --test
1568, --test
3136, --test
6272, --test
945534534e5568156, --test]]--cursed enough
} or {5,10,15,20,25,30}
local boostCount = 0
function ClearBoostStats()
BoostedIntensity = 0
boostCount = 0
Ingamestats.intBoostCurrentCost = boostCosts[boostCount+1]
end
ReplicatedStorage.Remote.BoostIntensity.OnServerEvent:Connect(function(player,
agreed)
if Ingamestats.boostingEnabled == false then
return
end
if boostCosts[boostCount+1] == nil then
return
end
if Intensity+getIntensityChange(0,Intensity,BoostedIntensity) >= 6.99 then
return
end
local boostCost = boostCosts[boostCount+1]
if (not agreed) and boostCount > 1 then
ReplicatedStorage.Remote.BoostIntensity:FireClient(player, "The current
intensity boost is ".. BoostedIntensity ..". Boosting by another 0.5 will cost "..
boostCost .." Gems.", "Intensity Boost", true)
return
end
if MainData[player.Name].plrData.stats.gems >= boostCost then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems - boostCost
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
boostCount = boostCount + 1
Ingamestats.intBoostCurrentCost = boostCosts[boostCount+1] or "Max"
if boostCosts[boostCount+1] == nil then
Ingamestats.boostingEnabled = false
end
BoostedIntensity = BoostedIntensity + (chaos and 1 or 0.5)
UpdIngameStatsFunc()
local minInt =
math.clamp(Intensity+getIntensityChange(0,Intensity,BoostedIntensity),1,6.99)
Alert:FireAllClients((player.Name .. " boosted! Min. Intensity: %.2f -
%.2f"):format(minInt,
math.clamp(Intensity+getIntensityChange(1,Intensity,BoostedIntensity),1,6.99)),
difColors[math.floor(minInt)] or nil, nil, minInt >= 6.99 and 'rainbow' or nil)
Sound:FireAllClients(1044088048, 5, 1 + (0.05 * boostCount))
else
return
end
end)
------------------------------------------------------------
local function ExitTitleFired(player)
player:LoadCharacter()
end
ExitTitle.OnServerEvent:Connect(ExitTitleFired)
------------------------------------------------------------
LoadedMap.OnServerEvent:Connect(function(player)
--local done = false
for i = 1, #NWaiting do
if NWaiting[i] == player then
--done = true
table.insert(Loaded, player)
UpdLoadScreen:FireClient(player, loadingmsg)
if playing == true then
player.Character.HumanoidRootPart.Anchored = false
end
return
end
end
for i = 1, #curPlaying do
if curPlaying[i] == player then
--done = true
table.insert(Loaded, player)
UpdLoadScreen:FireClient(player, loadingmsg)
if playing == true then
player.Character.HumanoidRootPart.Anchored = false
end
return
end
end
end)

local function UpdLoading(message)


loadingmsg = message
for i = 1, #Loaded do
if Loaded[i] ~= nil then
UpdLoadScreen:FireClient(Loaded[i],message)
end
end
end

ReplicatedStorage.Remote.MapHistory.OnInvoke = function()
return playeds
end

Codes = require(script:WaitForChild("Codes"))

ReqCode.OnServerEvent:connect(function(player, key, code)


if -PassKey ~= key then
Alert:FireClient(player,"An error was occured. Reporting an error to
debugger...")
return
end
--if codes[code] then
if Codes.codes[code] then
if table.find(MainData[player.Name].plrData.usedCodes, code) then --
redeemed[code] then
Alert:FireClient(player,"Already redeemed.")
return "Already redeemed."
else
--MainData[player.Name].plrData.stats[codes[code].reward] =
MainData[player.Name].plrData.stats[codes[code].reward] + codes[code].ammount
for i,v in pairs(Codes.codes[code].rewards) do
if v.reward ~= nil and v.amount ~= nil or v.id ~= nil then
if v.reward == "gems" or v.reward == "coins" then
MainData[player.Name].plrData.stats[v.reward] =
MainData[player.Name].plrData.stats[v.reward] + v.amount
elseif v.reward == "inventory" or v.reward == "item"
then
if v.id ~= nil then

table.insert(MainData[player.Name].plrData.inventory,
(#MainData[player.Name].plrData.inventory + 1),v.id)
pcall(function()
Notify:FireClient(player,"You have
been awarded with " .. GetitmTab(v.id).name .. "!", "Item Awarded")
end)
end
end
end
end
end
Givexp(player,Codes.codes[code].xp or 0)
table.insert(MainData[player.Name].plrData.usedCodes, code) --
redeemed[code] = true
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
--Alert:FireClient(player,codes[code].msg)
Alert:FireClient(player,Codes.codes[code].msg or "Code Accepted!")
--return codes[code].msg
return Codes.codes[code].msg or "Code Accepted!"
elseif Codes.expired[code] then
Alert:FireClient(player,"Invalid Code! (Expired)")
return "Invalid Code! (Expired)"
else
Alert:FireClient(player,"Invalid Code!")
return "Invalid Code!"
end
end)

function countAssets(item)
local newAssets = item:GetChildren()
local count = #newAssets
for _, c in pairs(newAssets) do
count = count + countAssets(c)
end
return count
end
function IsButton(object)
assert(typeof(object) == "Instance")

local isButton, nameExtension = false, nil

if object:IsA("Model") and string.sub(object.Name, 1, 7) == "_Button" then


isButton, nameExtension = true, string.sub(object.Name, 8, -1)
end

return isButton, nameExtension


end
function GetButtons(map)
local mapButtons = {}
for i, item in pairs(map:GetDescendants()) do
local isButton, nameExtension = IsButton(item)
if isButton then
local id = tonumber(nameExtension)
if id ~= nil and id == math.floor(id) then -- Is this an integer?
mapButtons[id] = item
end
end
end
return mapButtons
end
--[[local ropesdata = {}
game.ReplicatedStorage.Remote.UpdRopesData.OnServerInvoke =
function(player,startmark)
return MapInitModule.getRopeData(startmark)
end]]
--local loadedmapvals = false
local btnFuncs = {}
function GepMapValsFunc()
local Map = workspace.Multiplayer:WaitForChild("Map")
local Button = game.ServerStorage.Bindables.BtnPress.Event
local lib = {
Map = Map,
Button = Button,
btnFuncs = btnFuncs,
Script = MapScript,
}
return lib
end

game.ServerStorage.Bindables.GetPlaying.OnInvoke = function()
return curPlaying
end

local devProduct1 = 1670886508 -- 50 coins


local devProduct2 = 1670886510 -- 100 coins
local devProduct3 = 1670886511 -- 25 gems
local devProduct4 = 1670886509 -- 50 gems

local MarketplaceService = game:GetService("MarketplaceService")

local function processReceipt(receiptInfo)


local player =
game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print(receiptInfo.ProductId)
if receiptInfo.ProductId == devProduct1 then
MainData[player.Name].plrData.stats.coins =
MainData[player.Name].plrData.stats.coins + 50
player.PlayerGui.GameGui.HUD.MenuToggle.Stats.CoinAmt.Amount.Text =
MainData[player.Name].plrData.stats.coins
player.PlayerGui.GameGui.Shop.TopBar.Currency.Coins.Amount.Text =
MainData[player.Name].plrData.stats.coins
Alert:FireClient(player, "Successfully bought 50 Coins!",
Color3.fromRGB(0, 255, 0))
elseif receiptInfo.ProductId == devProduct2 then
MainData[player.Name].plrData.stats.coins =
MainData[player.Name].plrData.stats.coins + 100
player.PlayerGui.GameGui.HUD.MenuToggle.Stats.CoinAmt.Amount.Text =
MainData[player.Name].plrData.stats.coins
player.PlayerGui.GameGui.Shop.TopBar.Currency.Coins.Amount.Text =
MainData[player.Name].plrData.stats.coins
Alert:FireClient(player, "Successfully bought 100 Coins!",
Color3.fromRGB(0, 255, 0))
elseif receiptInfo.ProductId == devProduct3 then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems + 25
player.PlayerGui.GameGui.HUD.MenuToggle.Stats.GemAmt.Amount.Text =
MainData[player.Name].plrData.stats.gems
player.PlayerGui.GameGui.Shop.TopBar.Currency.Gems.Amount.Text =
MainData[player.Name].plrData.stats.gems
Alert:FireClient(player, "Successfully bought 25 Gems!",
Color3.fromRGB(0, 255, 0))
elseif receiptInfo.ProductId == devProduct4 then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems + 50
player.PlayerGui.GameGui.HUD.MenuToggle.Stats.GemAmt.Amount.Text =
MainData[player.Name].plrData.stats.gems
player.PlayerGui.GameGui.Shop.TopBar.Currency.Gems.Amount.Text =
MainData[player.Name].plrData.stats.gems
Alert:FireClient(player, "Successfully bought 50 Gems!",
Color3.fromRGB(0, 255, 0))
end
local itemL = GetitmTab(receiptInfo.ProductId)
if itemL ~= nil then
if itemL.catagory == "Currency" then
if itemL.curReward == 0 then
MainData[player.Name].plrData.stats.coins =
MainData[player.Name].plrData.stats.coins + itemL.reward
elseif itemL.curReward == 1 then
MainData[player.Name].plrData.stats.gems =
MainData[player.Name].plrData.stats.gems + itemL.reward
end
UpdPlayerData:FireClient(player, MainData[player.Name].plrData)
Alert:FireClient(player, "Successfully bought "..itemL.name.."!",
Color3.fromRGB(0, 255, 0))
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt

GetMapVals.OnInvoke = GepMapValsFunc

Winsinrow = 0

local function lerpable(value)


local suc, res = pcall(function()
return value.Lerp
end)
if type(res) == 'function' then
return true
end
return false
end

local function lerpNumber(start, goal, alpha)


return start + (goal - start) * alpha
end
local playeda = false
local lockedcount = false
spawn(function() -- count lock or not
while task.wait() do
if LockedCurDif ~= 0 and Playing == false and lockcounted == false then
lockcounted = true
if LockedCurDifLeft >= 3 then
lockedcount = true
end
if LockedCurDifLeft <= 0 then

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Visible = false

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Visible = false

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Difficulty.Size =
UDim2.new(1, 0, 1, 0)
LockedCurDif = 0
LockedCurDifLeft = 0
else

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Visible = true

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Difficulty.Size =
UDim2.new(0.83, 0, 1, 0)

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Arrow.ImageColor3 =
difColors[LockedCurDif]

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Locked.Amount.Text =
LockedCurDifLeft
LockedCurDifLeft = LockedCurDifLeft - 1
if CurDif < LockedCurDif then
CurDif = LockedCurDif
end
if LockedCurDif == 5 then
Winsinrow = 0
CurDif = 5
SpcRnd = true
end
end
end
end
end)
function NearestValue(table, number)
local smallestSoFar, smallestIndex
smallestSoFar = nil
smallestIndex = nil
for i, y in ipairs(table) do
if not smallestSoFar or (math.abs(number-y) < smallestSoFar) then
smallestSoFar = math.abs(number-y)
smallestIndex = i
end
end
return smallestIndex, table[smallestIndex]
end
game.ServerStorage.Bindables.BtnPressXP.Event:Connect(function(player,btnid,isgroup
,isexplosive)
local xp = isgroup and 20 or 10
if isgroup then
plrGroupBtnData[player.Name] += 1
else
plrBtnData[player.Name] += 1
end
Alert:FireClient(player,'Pressed Button #'..btnid..': '..xp..'XP',
Color3.new(0.945098, 0.858824, 0.501961))
if workspace.Multiplayer:FindFirstChild("Map") and
workspace.Multiplayer.Map:FindFirstChild("Timeline_Wrapper") and
workspace.Multiplayer.Map.Timeline_Wrapper:IsA("Script") then
-- handles timelines sound (already there in mapinitmodule)
else
Sound:FireClient(player,1523860403,0.5,1.35)
end
end)
game.ServerStorage.Bindables.UpdButtonCount.Event:Connect(function(count)
Ingamestats.currentButton = (count ~= 0) and (count - 1) or
Ingamestats.totalButtons
UpdIngameStatsFunc()
end)
game.ServerStorage.Bindables.EnableAndGetExitRegions.OnInvoke = function()
Ingamestats.currentButton = 0
UpdIngameStatsFunc()
return exit
end
game.ServerStorage.Bindables.GetPlayerGameState.OnInvoke = function(player)
if table.find(curPlaying,player) then
return 'playing'
elseif table.find(Survivors,player) then
return 'survived'
else
return 'lobby'
end
end
ReplicatedStorage.Remote.ReqLostPages.OnServerInvoke = function(player, target)
return {} --wip
end
game.ServerStorage.Bindables.LostPageCollected.Event:Connect(function(player,id,par
t)
table.insert(plrSumData[player.Name][#plrSumData[player.Name]], {
"LostPage",
50,
1
})
end)
game.ServerStorage.Bindables.ReqIngamePlayerCount.OnInvoke = function()
return #curPlaying
end
ReplicatedStorage.Remote.PressedMapButton.OnServerEvent:Connect(function(plr,hit)
MapInitModule.serverButtonPressed(plr,hit)
end)

while wait() do
if #Waiting > 0 and Playing == false or playeda == true then
Ingamestats.gameStatus = "intermission"
Ingamestats.timerStart = tick()
Ingamestats.timerDuration = waitingtime
Ingamestats.boostingEnabled = false
if maptest and #game:GetService("Players"):GetPlayers() <= 1 and false
then
Ingamestats.timerDuration = 1
end
UpdIngameStatsFunc()
--
workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage:TweenSize(UDim2.new(0
, 0, 1, 0), nil, "Linear", maptest and 5 or waitingtime, true)
local mok = {}
--if Maps[0][1] ~= nil then mok[#mok+1] = 0 end
for i = 1,#Maps do
if #Maps[i] ~= 0 then mok[#mok+1] = i end
end
local confirmDif = ActualDif(Intensity)
if table.find(mok, confirmDif) then
startNewVote(confirmDif)
else
local dok = mok if table.find(dok,PlayedDif) then
pcall(function() dok:remove(table.find(dok,PlayedDif)) end) if dok[1] == nil then
dok = mok end end
local i,val
local suc,err = pcall(function()
i,val = NearestValue(dok,confirmDif)
end)
if val ~= nil then
startNewVote(val)
else
Waiting = NWaiting
NWaiting = {}
Playing = false
game.ReplicatedStorage.Remote.Alert:FireAllClients("Unable
to start the game. Please rejoin.",Color3.fromRGB(255,0,0))
continue -- Luau statement
end
end
local liftwait = tick()
repeat task.wait()
if #game:GetService("Players"):GetPlayers() <= 1 and ((voting ==
false) or (votedFirst == true)) then
Ingamestats.timerDuration = 1 -- // break lift waits once
player voted map, or only one map installed, on solo server
UpdIngameStatsFunc() --NOTE IT IS THE RIGHT SCRIPT THAT
MAKES UH YOU UNDERSTOOD
end
until tick() - liftwait > Ingamestats.timerDuration
ReplicatedStorage.Remote.UpdMapVote:FireAllClients()
if workspace.Multiplayer:FindFirstChild("Map") then
--ropesdata = {}
if script.Parent:FindFirstChild("EvtString_Active") then
script.Parent:FindFirstChild("EvtString_Active"):Destroy()
end
workspace.Multiplayer:FindFirstChild("Map"):Destroy()
end
if #Waiting > 0 then
UpdIngameStatsFunc()
--[[if Winsinrow >= 3 then
--Winsinrow = 0
CurDif = 4
SpcRnd = true
elseif Winsinrow >= 4 then
Winsinrow = 0
CurDif = 4
SpcRnd = true
end]]
CurDif = math.clamp(math.floor(Intensity),1,6) - 1
NWaiting = Waiting
Waiting = {}
Loaded = {}
curPlaying = {}
Survivors = {}
UpdLoading("Waiting for Server")
playeda = true
abc = false
local Mapss = Maps[confirmDif] --[CurDif]
local plsmapr = false
if Mapss and Mapss[1] == nil then
for i,v in pairs(Maps) do
if v[1] ~= nil then
plsmapr = true
Mapss = v
end
end
elseif not Mapss then
warn("Reached to impossible area, it may occur some
error.")
end
local counts = #MapStorage:GetChildren()
if counts <= 0 then
Playing = false
curPlaying = {}
NWaiting = {}
playeda = false
Alert:FireAllClients(":( The game cannot start. There are
no maps.",Color3.fromRGB(255,0,0))
continue -- Luau statement
end
local rand = nil
local selmap = nil
selmap = pickMap()
if nextmap ~= nil then
selmap = nextmap
if nextmap:FindFirstChild("Settings") then
if nextmap.Settings:FindFirstChild("Difficulty") then
--CurDif =
math.clamp(nextmap.Settings.Difficulty.Value,1,6) - 1
elseif nextmap.Settings:GetAttribute("Difficulty")
then
--CurDif =
math.clamp(nextmap.Settings:GetAttribute("Difficulty"),1,6) - 1
end
--Intensity = CurDif + 1
end
nextmap = nil
RefreshMaps(true)
UpdMapListPart(selmap)
Alert:FireAllClients("The map has been overridden by
privileged player(s).")
end
ReplicatedStorage.Remote.MapHistory.NewMap:Fire(selmap)
if selmap ~= nil and selmap:FindFirstChild("Settings") then
if selmap.Settings:FindFirstChild("Difficulty") then
if type(tonumber(selmap.Settings.Difficulty.Value))
== "number" then
PlayedDif =
math.clamp(tonumber(selmap.Settings.Difficulty.Value),1,6)
end
elseif selmap.Settings:GetAttribute("Difficulty") then
if
type(tonumber(selmap.Settings:GetAttribute("Difficulty"))) == "number" then
PlayedDif =
math.clamp(tonumber(selmap.Settings:GetAttribute("Difficulty")),1,6)
end
end
end
table.insert(playeds,(#playeds+1),selmap)
local Map = selmap:Clone()
local enablethis = {}
for i,v in ipairs(selmap:GetDescendants()) do
if v:IsA("Script") and v.Disabled == false then
if v.Name ~= "EventScript" then
table.insert(enablethis,(#enablethis+1),v)
end
v.Disabled = true
end
end
local mapinfos = {
Name = Map.Settings:GetAttribute("MapName") or
(Map.Settings:FindFirstChild("MapName") and Map.Settings.MapName.Value) or '',
Difficulty =
math.clamp(tonumber(Map.Settings:GetAttribute("Difficulty")) or
tonumber(Map.Settings:FindFirstChild("Difficulty") and
Map.Settings.Difficulty.Value) or 6,1,6),
Rate = Map.Settings:GetAttribute("Difficulty") or
(Map.Settings:FindFirstChild("Difficulty") and Map.Settings.Difficulty.Value) or "-
1.0",
Creator = Map.Settings:GetAttribute("Creator") or
(Map.Settings:FindFirstChild("Creator") and Map.Settings.Creator.Value) or '',
ImgID = Map.Settings:GetAttribute("MapImage") or
(Map.Settings:FindFirstChild("MapImage") and Map.Settings.MapImage.Value) or 0,
ButtonCount = #GetButtons(Map),
assetCount = Map.Settings:GetAttribute("AssetCount") or
countParts(Map),
highlight = Map.Settings:GetAttribute("Highlight") or
(Map.Settings:FindFirstChild("Highlight") and Map.Settings.Highlight.Value) or
false,
mapID = maptest and (Map.Settings:GetAttribute("MapID") or
(Map.Settings:FindFirstChild("MapID") and Map.Settings.MapID.Value) or '0') or nil
}
Ingamestats.mapName = mapinfos.Name
Ingamestats.mapImg = mapinfos.ImgID
Ingamestats.difficulty = ActualDif(Intensity) --
mapinfos.Difficulty
Ingamestats.intensity = Intensity --mapinfos.Difficulty
--wait(1)
exit = Map:FindFirstChild("ExitRegion", true)
if exit == nil then
for i = 1,#curPlaying do
if curPlaying[i] ~= nil then
Alert:FireClient(curPlaying[i],"An error
occured while loading map.")
warn("The map has no ExitRegion. Skipped.") --
new debug
if curPlaying[i].Character ~= nil then
curPlaying[i].Character.Humanoid.Health =
0
end
end
end
Playing = false
playeda = false
NWaiting = {}
curPlaying = {}
--
workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage:TweenSize(UDim2.new(1
, 0, 1, 0), nil, "Linear", 0, true)
continue
end
if workspace.Multiplayer:FindFirstChild("Map") then
--ropesdata = {}
workspace.Multiplayer:FindFirstChild("Map"):Destroy()
if script.Parent:FindFirstChild("Timelines") then
script.Parent.Timelines:Destroy()
end
end
--wait(1) --makes players wait 1 second before loading starts
for i = 1, #NWaiting do
UpdateGameState:FireClient(NWaiting[i], "loading",
mapinfos, Winsinrow + 1)
end
local event,forcedmirror = nil,nil
if forceevent ~= nil then
event,forcedmirror = MapInitModule.pickEvent(Map,forceevent
~= "none" and forceevent or nil)
elseif math.random(1,2) == 1 then
event,forcedmirror = MapInitModule.pickEvent(Map,true)
end
wait() --note set to 1 to make loading not instant
local lastBtnId = 1
while true do
local btn = Map:findFirstChild("_Button" .. lastBtnId,
true)
if btn then
lastBtnId = lastBtnId + 1
end
if not btn then
break
end
end
Ingamestats.totalButtons = lastBtnId
--workspace.Multiplayer:FindFirstChild("NewMap").Name = "Map"
local xmin,xmax = Map.Spawn.Position.X - (Map.Spawn.Size.X/2 *
0.8), Map.Spawn.Position.X + (Map.Spawn.Size.X/2 * 0.8)
local zmin,zmax = Map.Spawn.Position.Z - (Map.Spawn.Size.Z/2 *
0.8), Map.Spawn.Position.Z + (Map.Spawn.Size.Z/2 * 0.8)
for i = 1, #NWaiting do
if NWaiting[i] ~= nil and NWaiting[i].Character ~= nil then

local char = NWaiting[i].Character


pcall(function()
NWaiting[i].Character.HumanoidRootPart.Anchored
= true
end)
--[[pcall(function()
if
NWaiting[i].PlayerGui:FindFirstChild("MapUI") then
NWaiting[i].PlayerGui.MapUI:Destroy()
end
end)]]
spawn(function()
--wait(1)
--char.HumanoidRootPart.CFrame =
CFrame.new(Map.Spawn.Position.X, Map.Spawn.Position.Y + 5, Map.Spawn.Position.Z)
char.HumanoidRootPart.CFrame =
CFrame.new(math.random(xmin,xmax), Map.Spawn.Position.Y + (Map.Spawn.Size.Y/2) + 3,
math.random(zmin,zmax)) * CFrame.Angles(0,math.rad(Map.Spawn.Rotation.Y),0)
end)
table.insert(curPlaying, NWaiting[i])
end
end
UpdLoading("Waiting...") --in past text: Waiting For Players
NWaiting = {}
start = tick()
PAS = #curPlaying
Ingamestats.totalPlayers = PAS
while wait() do
if tick() - start >= 0 then --this part of script makes us
wait 5 seconds before game will load us into the map: basically by setting it to 0
we instantly loading in.
break
end
if #Loaded >= PAS then
break
end
end
spawn(function()
for i,v in ipairs(enablethis) do
spawn(function()
pcall(function()
v.Disabled = false
end)
end)
end
end)
UpdLoading("Loading Map...")
MapInitModule.preIntMap(Map,(math.random(10,20)/10),event)
local hasTimelines = nil
if Map:FindFirstChild("Timelines") then
hasTimelines = Map.Timelines
hasTimelines.Parent = script.Parent
end
Map.Parent = workspace.Multiplayer
if Map.Settings:GetAttribute("AssetCount") then
local counts = Map.Settings:GetAttribute("AssetCount")
while true do
wait(0.7)
if #Map:GetDescendants() >= counts then
break
end
end
end
UpdLoading("Waiting for Players")
if #curPlaying == 1 then
local wdt = tick()
while tick() - wdt <= 30 do
if #Loaded == #curPlaying then
break
end
UpdLoading("Waiting for "..#curPlaying - #Loaded.."
Player"..(#curPlaying - #Loaded > 1 and "s" or ""))
wait()
end
else
local wdt = tick()
while tick() - wdt <= 8 do
if #Loaded == #curPlaying then
break
end
UpdLoading("Waiting for "..#curPlaying - #Loaded.."
Player"..(#curPlaying - #Loaded > 1 and "s" or ""))
wait()
end
end
--[[local delayingplr = {}
if #Loaded ~= #curPlaying then
for i = 1,#curPlaying do
if curPlaying[i] ~= nil then
if not table.find(Loaded,curPlaying[i]) then
local plr = curPlaying[i]
table.remove(curPlaying,i)

game.ReplicatedStorage.Remote.Alert:FireClient(plr,"Timed out, returning to


lobby...",Color3.new(1,1,0))
if
plr.Character:FindFirstChild("Humanoid") then
plr.Character.Humanoid.Health = 0
end
end
end
end
wait(1)
end]]
UpdLoading("Waiting for Server")
--local eventinfo = MapInitModule.intMap(Map,event) this part of
script is used below
local xmin,xmax = Map.Spawn.Position.X - (Map.Spawn.Size.X/2 *
0.8), Map.Spawn.Position.X + (Map.Spawn.Size.X/2 * 0.8)
local zmin,zmax = Map.Spawn.Position.Z - (Map.Spawn.Size.Z/2 *
0.8), Map.Spawn.Position.Z + (Map.Spawn.Size.Z/2 * 0.8)
Ingamestats.gameStatus = "ingame"
UpdIngameStatsFunc()
for i = 1, #curPlaying do
plrSumData[curPlaying[i].Name]
[#plrSumData[curPlaying[i].Name] + 1] = {}
--[=[
table.insert(plrSumData[curPlaying[i].Name]
[#plrSumData[curPlaying[i].Name]], {
Map.Settings.MapName.Value,
--CurDif + 1
PlayedDif
})
--]=]
plrSumData[curPlaying[i].Name]
[#plrSumData[curPlaying[i].Name]].MapInfo = {
Name = Map.Settings:FindFirstChild("MapName") and
Map.Settings.MapName.Value or Map.Settings:GetAttribute("MapName"),
Difficulty = PlayedDif,
Image = Map.Settings:FindFirstChild("MapImage") and
Map.Settings.MapImage.Value or Map.Settings:GetAttribute("MapImage"),
AllPlayers = PAS
}
plrSumData[curPlaying[i].Name]
[#plrSumData[curPlaying[i].Name]].Buttons = {
Pressed = 0, --todo: make it show buttons you pressed
even if you died, for now it shows 0 everytime you die. note
Total = mapinfos.ButtonCount
}
spawn(function()
if maptest and
game:GetService("ServerScriptService").Modules:FindFirstChild("MapTest") and
game:GetService("ServerScriptService").Modules.MapTest:FindFirstChild("BGMEvent")
then

game:GetService("ServerScriptService").Modules.MapTest.BGMEvent:Fire(curPlaying[i],
Map.Settings:FindFirstChild("BGM") and Map.Settings.BGM.Value or
Map.Settings:GetAttribute("BGM"))
end
end)
UpdateGameState:FireClient(curPlaying[i], "ingame")
spawn(function()
if curPlaying[i].Character:FindFirstChild("PlrInfo")
then

curPlaying[i].Character.PlrInfo.Update.ShowInfo:Fire(curPlaying[i],nil,true)
end
curPlaying[i].Character.HumanoidRootPart.CFrame =
CFrame.new(math.random(xmin,xmax), Map.Spawn.Position.Y + (Map.Spawn.Size.Y/2) + 3,
math.random(zmin,zmax)) * CFrame.Angles(0,math.rad(Map.Spawn.Rotation.Y),0)
--wait(1)
--if table.find(Loaded,curPlaying[i]) then
--
curPlaying[i].Character.HumanoidRootPart.Anchored = false
--end
end)
end
--task.wait(1) -- delay for good performance
playing = true
if lockedcount == false then
lockcounted = false
else
lockedcount = false
end
--
workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage:TweenSize(UDim2.new(1
, 0, 1, 0), nil, "Linear", 0, true)
workspace.Lobby.GameInfo.SurfaceGui.Frame.Players.Text =
tostring(#curPlaying).."/"..tostring(#curPlaying).." Players"
col = difColors[Map.Settings:FindFirstChild("Difficulty") and
Map.Settings.Difficulty.Value or Map.Settings:GetAttribute("Difficulty")]
diftext = tabDif[Map.Settings:FindFirstChild("Difficulty") and
Map.Settings.Difficulty.Value or Map.Settings:GetAttribute("Difficulty")]
if col == nil then
col = Color3.new(0, 0, 0)
end
if diftext == nil then
diftext = "Unknown"
end

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Difficulty.Text =
diftext .. ": " .. (Map.Settings:FindFirstChild("Difficulty") and
Map.Settings.Difficulty.Value or Map.Settings:GetAttribute("Difficulty")) --note
put "Intensity" later

workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.BackgroundColor3 = col
--
workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.LockedUI.Arrow.ImageColor3 =
col
workspace.Lobby.GameInfo.SurfaceGui.Frame.MapName.Text =
(Map.Settings:FindFirstChild("MapName") and Map.Settings.MapName.Value or
Map.Settings:GetAttribute("MapName"))

pcall(function()workspace.Lobby.GameInfo.SurfaceGui.Frame.Creator.Text =
"Creators: " .. (Map.Settings:FindFirstChild("Creator") and
Map.Settings.Creator.Value or Map.Settings:GetAttribute("Creator") or '') end)
workspace.Lobby.GameInfo.SurfaceGui.Frame.Imgs.MapImg.Image =
"rbxassetid://"..tostring(Map.Settings:FindFirstChild("MapImage") and
Map.Settings.MapImage.Value or Map.Settings:GetAttribute("MapImage"))
workspace.Lobby.MapBG.SurfaceGui.Frame.MapImg.Image =
"rbxassetid://"..tostring(Map.Settings:FindFirstChild("MapImage") and
Map.Settings.MapImage.Value or Map.Settings:GetAttribute("MapImage"))
--task.wait(1)--0
Map.Name = "Map"
local msg = (Map.Settings:FindFirstChild("MapName") and
Map.Settings.MapName.Value or Map.Settings:GetAttribute("MapName")).."
["..diftext.."] by "..(Map.Settings:FindFirstChild("Creator") and
Map.Settings.Creator.Value or Map.Settings:GetAttribute("Creator") or '')
local maxtime = 120
if Map.Settings:FindFirstChild("MaxTime") ~= nil then
if Map.Settings.MaxTime.Value >= 10 and
Map.Settings.MaxTime.Value <= 300 then
maxtime = Map.Settings.MaxTime.Value
end
elseif Map.Settings:GetAttribute("MaxTime") ~= nil then
if Map.Settings:GetAttribute("MaxTime") >= 10 and
Map.Settings:GetAttribute("MaxTime") <= 300 then
maxtime = Map.Settings:GetAttribute("MaxTime")
end
end
Ingamestats.timerStart = tick()
Ingamestats.timerDuration = maxtime
Ingamestats.boostingEnabled = true
UpdIngameStatsFunc()
task.wait(1) --delay to let everything load afterwards
local eventinfo = MapInitModule.intMap(Map,event)
pcall(function()
game.Workspace.Multiplayer.PlayingBGM.Value =
Map.Settings:FindFirstChild("BGM") and Map.Settings.BGM.Value or
Map.Settings:GetAttribute("BGM")
end)
loadedmapvals = false
if eventinfo.eventStartAlert ~= "" then
for i = 1, #curPlaying do
--Alert:FireClient(curPlaying[i], msg, col, 3, false)
if eventinfo.eventType == "rescue" then

Sound:FireClient(curPlaying[i],15020055493,0.5,1.05)

Alert:FireClient(curPlaying[i],eventinfo.eventStartAlert,Color3.fromRGB(241,
219, 128),nil,"event")
elseif eventinfo.eventType == "thickfog" then

Sound:FireClient(curPlaying[i],15020045848,0.5,1)

Alert:FireClient(curPlaying[i],eventinfo.eventStartAlert,Color3.fromRGB(241,
77, 189),nil,"event")
elseif eventinfo.eventType == "explodingbuttons" then

Sound:FireClient(curPlaying[i],15020052113,0.5,1)

Alert:FireClient(curPlaying[i],eventinfo.eventStartAlert,Color3.fromRGB(170,
85, 0),nil,"event")
elseif eventinfo.eventType == "groupbuttons" then

Sound:FireClient(curPlaying[i],15020053230,0.5,1)

Alert:FireClient(curPlaying[i],eventinfo.eventStartAlert,Color3.fromRGB(0, 0,
255),nil,"event")
elseif eventinfo.eventType == "mirror" then

Sound:FireClient(curPlaying[i],15020048956,0.5,1.05)

Alert:FireClient(curPlaying[i],eventinfo.eventStartAlert,Color3.fromRGB(85,
170, 127),nil,"event")
elseif eventinfo.eventType == "lostpage" then

Sound:FireClient(curPlaying[i],15020054136,0.5,1)

Alert:FireClient(curPlaying[i],eventinfo.eventStartAlert,Color3.fromRGB(0,
255, 0),nil,"event")
end
end--v168, "eventmsg", Color3.fromRGB(241, 219, 128), nil,
"event"
else
Alert:FireAllClients(nil,nil,nil,"event")
end
for i = 1, #curPlaying do
if table.find(Loaded,curPlaying[i]) then
curPlaying[i].Character.HumanoidRootPart.Anchored =
false
end
end

MapInitModule.activateButton(1)
MapInitModule.startMapEvents(hasTimelines or
Map:FindFirstChild("EventString") or Map:FindFirstChild("EventScript"))

if Map:FindFirstChild("LocalEventScript") then
for i = 1, #curPlaying do
local a = Map.LocalEventScript:Clone()
a.Parent = curPlaying[i].Character
a.Disabled = false
end
end
if Map:FindFirstChild("EventLocal") then
for i = 1, #curPlaying do
local a = Map.EventLocal:Clone()
a.Parent = curPlaying[i].Character
a.Disabled = false
end
end

bestTime = maxtime

local success, err = pcall(function()


for _, v in next, curPlaying do
local MapName = Map.Settings:GetAttribute("MapName")
or (Map.Settings:FindFirstChild("MapName") and Map.Settings.MapName.Value)
local BestTime =
MainData[v.Name].plrData.gameplayStats.mapBestTimes[MapName]
if BestTime ~= nil then
bestTime = BestTime;
end

StartClientMapTimer:FireClient(v, maxtime, bestTime)


end
end)

if not success then


print(err)
end
Winsinrow = Winsinrow + 1
start = tick()
while wait() do
workspace.Lobby.GameInfo.SurfaceGui.Frame.Players.Text =
tostring(#curPlaying).."/"..tostring(PAS).." Players"
if tick() - start >= maxtime then
for i = 1, #curPlaying do
if curPlaying[i] ~= nil then
Alert:FireClient(curPlaying[i], "Exceeded
Max Time!", Color3.fromRGB(255, 255, 0), 5, false)
curPlaying[i].Character.Humanoid.Health =
0
end
end
break
end
if #curPlaying <= 0 then
break
end
if #Survivors >= PAS then
break
end
end
btnFuncs = {}
playing = false
Ingamestats.boostingEnabled = false
local backInts = Intensity
local boosted = BoostedIntensity ~= 0
local boosts = BoostedIntensity
Intensity = math.clamp(Intensity +
getIntensityChange(#Survivors / PAS, PlayedDif, BoostedIntensity),1,6.99)
Ingamestats.difficulty = ActualDif(Intensity)
Ingamestats.intensity = Intensity
ClearBoostStats()
UpdIngameStatsFunc()
for i = 1, #Survivors do
local difChange = ("???")

game.Workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.Difficulty.Text =
(difInfos[ActualDif(Intensity)].Name .. ": " .. Intensity)

game.Workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.BackgroundColor3 =
difInfos[ActualDif(Intensity)].Color
local calcd = getIntensityChange(#Survivors / PAS,
PlayedDif, BoostedIntensity)
difChange = backInts .. (calcd > 0 and " + " or " - ") ..
string.format('%.2f', (Intensity - backInts - (boosted and boosts or 0))) ..
(boosted and ' (+ ' .. boosts .. ' Boost)' or '') .. " = " .. Intensity
Alert:FireClient(Survivors[i], --"\
226\154\160\239\184\143"..
tostring(#Survivors).."/"..tostring(PAS).." Escaped:
"..difChange.." Int." --\226\154\160\239\184\143"
,
game.Workspace.Lobby.GameInfo.SurfaceGui.Frame.Difficulty.BackgroundColor3, 5--,
"event"
, false)--waitingtime, true) -- surviving map is not 'Map
Event', "event" is used for only 'Map Event'.
if Survivors[i].Character == nil then
if
Survivors[i].Character:FindFirstChild("EventLocal") then
Survivors[i].Character.EventLocal:Destroy()
elseif
Survivors[i].Character:FindFirstChild("LocalEventScript") then

Survivors[i].Character.LocalEventScript:Destroy()
end
end
end
wait(0)
if #Survivors > (PAS / 2) then
if CurDif >= 4 then
end
if CurDif < 4 then
CurDif = CurDif + 1
end
else
Winsinrow = 0
if CurDif > 0 then
CurDif = CurDif - 1
end
end
if SpcRnd == true then
CurDif = 3
end
if lockedcount == false then
lockcounted = false
else
lockedcount = false
end
--
workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage:TweenSize(UDim2.new(0
, 0, 1, 0), nil, "Linear", 0, true)
workspace.Lobby.GameInfo.SurfaceGui.Frame.MapName.Text =
("Ready!")
workspace.Lobby.GameInfo.SurfaceGui.Frame.Players.Text =
("Waiting for Players")
Playing = false
SpcRnd = false
wait(0)
for i = 1, #Survivors do
if Survivors[i] and Survivors[i].Character then
local suc,err = pcall(function()
spawn(function()
local survivor = Survivors[i]
local waitingstart = tick()
while tick() - waitingstart < 8 do
wait()
if survivor == nil then
break
end
end
pcall(function()

Survivors[i].Character.HumanoidRootPart.Anchored = true
end)
end)
table.insert(Waiting, Survivors[i])
UpdPlayerData:FireClient(Survivors[i],
MainData[Survivors[i].Name].plrData)
end)
if not suc then
pcall(function()
--print("Error Line 2773~2780: " .. err)
Alert:FireClient(Survivors[i],"An error
occured on teleporting.",Color3.fromRGB(255,0,0))
end)
end
end
end
else
playeda = false
Ingamestats.gameStatus = "intermission"
timerstart = 0
Ingamestats.timerStart = 0
Ingamestats.timerDuration = -1
Ingamestats.boostingEnabled = true
UpdIngameStatsFunc()
--
workspace.Lobby.GameInfo.SurfaceGui.Frame.TimeLeft.Percentage:TweenSize(UDim2.new(1
, 0, 1, 0), nil, "Linear", 0, true)
wait(0)
end
end
end

You might also like