Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script.Name = "serverCode"
- -- PUT ALL YOUR MAPS in game.Lighting.maps
- -- MAKE A MODEL IN LIGHTING CALLED maps AND PUT ALL THE MAPS THERE
- --====================================================================================--
- --========================================Game Settings============================================--
- --====================================================================================--
- local countdownTime = 10; -- seconds for countdown
- local timeBetweenRounds = 10; -- seconds between rounds
- local hoverboardGamePasses = {
- ['938736673'] = "GearNameInLighting"; -- The first number is the gamepassId and the second is the name of gear in the lighting they get
- ['387436634'] = "AnotherGearName";
- }
- local swordGamePasses = {
- ['938736673'] = "GearNameInLighting";
- ['387436634'] = "AnotherGearName";
- }
- --====================================================================================--
- --====================================================================================--
- --====================================================================================--
- local spectator = Game.Lighting:WaitForChild([==[Spectate]==]); -- name of spectator tool/hopperbin
- local shopGui = Game.Lighting:WaitForChild([==[Shop]==]); -- Name of shopGui is Shop
- local mapDirectory = game.Lighting:FindFirstChild("maps"); mapDirectory = mapDirectory:GetChildren()
- local map;
- local lobby = Workspace.Lobby
- local Create = assert(LoadLibrary("RbxUtility")).Create
- local timer = script:FindFirstChild("timer") and script.timer or Create("IntValue"){
- Name = "timer",
- Parent = script
- }
- local function updateMap()
- local newMap = mapDirectory[math.random(1, #mapDirectory)]
- newMap:Clone().Parent = workspace
- map = workspace:WaitForChild("map")
- wait(0.5)
- end
- local function giveSpectate()
- for i,v in pairs(Game.Players:GetPlayers()) do
- if not v.Backpack:FindFirstChild(spectator.Name) then
- spectator:Clone().Parent = v.Backpack
- end
- end
- end
- local function giveSpectateTo(pl)
- if not pl.Backpack:FindFirstChild(spectator.Name) then
- spectator:Clone().Parent = pl.Backpack
- end
- end
- local function removeSpectate()
- for i,v in pairs(Game.Players:GetPlayers()) do
- if v.Backpack:FindFirstChild(spectator.Name) then
- v.Backpack[spectator.Name]:Destroy();
- end
- end
- end
- local function ToggleShopGui(bool, pl)
- if bool then
- shopGui:Clone().Parent = pl:WaitForChild("PlayerGui");
- else
- pcall(function()
- pl.PlayerGui.Shop:Destroy();
- end)
- end
- end
- local function teleportToMap()
- teleportTo = { }
- for _, object in pairs(map:GetChildren()) do
- if object.Name == "teleportTo" then
- table.insert(teleportTo, object.Position)
- end
- end
- for _, player in pairs(game.Players:GetPlayers()) do
- if workspace:FindFirstChild(player.Name) and player:FindFirstChild("isInMap") then
- player.Character:MoveTo(teleportTo[math.random(1, #teleportTo)] + Vector3.new(0, 5, 0))
- player.isInMap.Value = true
- end
- end
- end
- local function give(name)
- for _, player in pairs(game.Players:GetPlayers()) do
- if player:FindFirstChild(name) then
- if game.Lighting:FindFirstChild(player[name].Value) then
- game.Lighting[player[name].Value]:Clone().Parent = player.Backpack
- if name == "board" then
- for i,v in pairs(player.BoughtItems.Hoverboards:GetChildren()) do
- v:Clone().Parent = player.Backpack
- end
- elseif name == "sword" then
- for i,v in pairs(player.BoughtItems.Swords:GetChildren()) do
- v:Clone().Parent = player.Backpack
- end
- end
- end
- end
- end
- if name == "board" then
- for i,v in pairs(game.Players:GetPlayers()) do
- local s = Game:GetService([==[GamePassService]==]);
- for k,j in pairs(hoverboardGamePasses) do
- if s:PlayerHasPass(v.userId, tonumber(k)) then
- Game.Lighting[j]:Clone().Parent = v.Backpack
- end
- end
- end
- elseif name == "sword" then
- for i,v in pairs(game.Players:GetPlayers()) do
- local s = Game:GetService([==[GamePassService]==]);
- for k,j in pairs(swordGamePasses) do
- if s:PlayerHasPass(v.userId, tonumber(k)) then
- Game.Lighting[j]:Clone().Parent = v.Backpack
- end
- end
- end
- end
- end
- local function countDown()
- local door = map:FindFirstChild("door")
- door.CanCollide = true
- door.Transparency = 0.5
- for i = countdownTime, 1, -1 do
- timer.Value = i
- wait(1)
- end
- for i = 0.5, 1, 0.1 do
- door.Transparency = i
- wait(0.03)
- end
- door.CanCollide = false
- end
- local function waitForWinner()
- local door = map:FindFirstChild("door")
- local alreadyWon = false
- local lastWinner = nil;
- door.Touched:connect(function(part)
- local humanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
- if humanoid and not alreadyWon then
- local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
- if player:FindFirstChild("wonRound") then
- player.wonRound.Value = not player.wonRound.Value
- alreadyWon = true
- lastWinner = player
- end
- end
- end)
- repeat wait(0.5) until alreadyWon
- return lastWinner;
- end
- local function teleportToLobby(lastWinner)
- local teleportTo = { }
- for _, object in pairs(lobby:GetChildren()) do
- if object.Name == "teleportTo" then
- table.insert(teleportTo, object.Position)
- end
- end
- lobby.Leader.Decal.Texture = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=" .. lastWinner.Name;
- for _, player in pairs(game.Players:GetPlayers()) do
- if player:FindFirstChild("isInMap") then
- if player.isInMap.Value then
- player.Character:MoveTo(teleportTo[math.random(1, #teleportTo)] + Vector3.new(0, 5, 0))
- player.isInMap.Value = false
- end
- end
- end
- end
- local function startRound()
- updateMap()
- removeSpectate();
- teleportToMap()
- for i,v in pairs(Game.Players:GetPlayers()) do
- ToggleShopGui(false,v);
- end
- give("board")
- countDown()
- wait(10)
- give("sword")
- teleportToLobby(waitForWinner())
- for i,v in pairs(Game.Players:GetPlayers()) do
- ToggleShopGui(true,v);
- end
- end
- local function intermission()
- repeat wait(1) until game.Players.NumPlayers > 1
- for i = timeBetweenRounds, 1, -1 do
- timer.Value = i
- wait(1)
- if not game.Players.NumPlayers > 1 then
- return false
- end
- end
- return true
- end
- game.Players.PlayerAdded:connect(function(player)
- Create("StringValue"){
- Name = "board",
- Parent = player
- }
- Create("StringValue"){
- Name = "sword",
- Parent = player
- }
- Create("BoolValue"){
- Name = "isInMap",
- Parent = player
- }
- Create("BoolValue"){
- Name = "wonRound",
- Parent = player
- }
- Create("BoolValue"){
- Name = "hasGamePass",
- Parent = player
- }
- Create("IntValue"){
- Name = "leaderboard",
- Parent = player
- }
- Create("IntValue"){
- Name = "Points",
- Parent = player:WaitForChild("leaderboard")
- }
- Create("IntValue"){
- Name = "Kills",
- Parent = player:WaitForChild("leaderboard")
- }
- Create("Model"){
- Name = "BoughtItems",
- Parent = player
- }
- Create("Model"){
- Name = "Hoverboards",
- Parent = player:WaitForChild("BoughtItems");
- }
- Create("Model"){
- Name = "Swords",
- Parent = player:WaitForChild([===================[BoughtItems]===================]);
- }
- player:WaitForChild("Kills").Changed:connect(function()
- local points = player:WaitForChild("Points")
- local earnedPoints = player:WaitForChild("hasGamePass").Value and 100 or 50
- points.Value = points.Value + earnedPoints
- end)
- player:WaitForChild("wonRound").Changed:connect(function()
- local points = player:WaitForChild("Points")
- local earnedPoints = player:WaitForChild("hasGamePass").Value and 500 or 200
- points.Value = points.Value + earnedPoints
- end)
- player.CharacterAdded:connect(function(character)
- if not player.isInMap.Value then
- giveSpectateTo(player);
- end
- workspace:WaitForChild(player.Name)
- character:WaitForChild("Humanoid").Died:connect(function()
- player.isInMap.Value = false
- end)
- end)
- end)
- while true do
- local interrupted = intermission()
- if not interrupted then
- startRound()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement