Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- status = game.ReplicatedStorage.Values.Status
- plrstowin = 1
- minplrs = 2
- intermissiontime = 30
- gametime = 240
- loadtime = 10
- starttime = 3
- money = 200
- mapvotetime = 20
- vote1 = workspace.MapVotePad1
- vote2 = workspace.MapVotePad2
- vote3 = workspace.MapVotePad3
- xp = 40
- --game loop
- while true do
- local won = false
- if #game.Players:GetPlayers() >= minplrs then
- --start game
- for i = intermissiontime,1,-1 do
- status.Value = "Intermission... "..i
- wait(1)
- end
- local maps = game.ReplicatedStorage.Maps:GetChildren()
- local ch1
- local ch2
- local ch3
- ch1 = maps[math.random(1,#maps)]
- repeat
- ch2 = maps[math.random(1,#maps)]
- until ch2 ~= ch1
- repeat
- ch3 = maps[math.random(1,#maps)]
- until ch3 ~= ch1 and ch3 ~= ch2
- print(ch1,ch2,ch3)
- vote1.Map.Value = ch1.Name
- vote2.Map.Value = ch2.Name
- vote3.Map.Value = ch3.Name
- vote1.Voting.Value = true
- vote2.Voting.Value = true
- vote3.Voting.Value = true
- for i, v in pairs(game.Players:GetChildren()) do
- v:WaitForChild("MapVote").Value = ""
- end
- for i = mapvotetime,1,-1 do
- status.Value = "Map vote... "..i
- wait(1)
- end
- vote1.Voting.Value = false
- vote2.Voting.Value = false
- vote3.Voting.Value = false
- local v1 = vote1.Votes.Value
- local v2 = vote2.Votes.Value
- local v3 = vote3.Votes.Value
- local chosenmap
- if v1 > v2 and v1 > v3 then
- status.Value = "The chosen map is "..vote1.Map.Value.." by "..game.ReplicatedStorage.Maps[vote1.Map.Value].Creator.Value
- chosenmap = vote1.Map.Value
- wait(2)
- elseif v2 > v1 and v2 > v3 then
- status.Value = "The chosen map is "..vote2.Map.Value.." by "..game.ReplicatedStorage.Maps[vote2.Map.Value].Creator.Value
- chosenmap = vote2.Map.Value
- wait(2)
- elseif v3 > v1 and v3 > v2 then
- status.Value = "The chosen map is "..vote3.Map.Value.." by "..game.ReplicatedStorage.Maps[vote3.Map.Value].Creator.Value
- chosenmap = vote3.Map.Value
- wait(2)
- else
- local mapss = {vote1.Map.Value,vote2.Map.Value,vote3.Map.Value}
- chosenmap = mapss[math.random(1,#mapss)]
- status.Value = "The chosen map is "..chosenmap
- wait(2)
- end
- for i, v in pairs(game.Players:GetChildren()) do
- if v:FindFirstChild("MapVote") then
- v.MapVote.Value = ""
- end
- end
- vote1.Map.Value = ""
- vote1.Votes.Value = 0
- vote2.Map.Value = ""
- vote2.Votes.Value = 0
- vote3.Map.Value = ""
- vote3.Votes.Value = 0
- local mapclone = game.ReplicatedStorage.Maps[chosenmap]:Clone()
- if mapclone.Name == "Si-Fi City" then
- game.Lighting.ClockTime = 0
- end
- mapclone.Parent = workspace
- for i, v in pairs(mapclone:GetChildren()) do
- if v:FindFirstChild("Chest") then
- v.Parent = workspace
- end
- end
- for i = loadtime,1,-1 do
- status.Value = "Loading map..."
- wait(1)
- end
- status.Value = "Starting game!"
- wait(starttime)
- game.ReplicatedStorage.Values.GameRunning.Value = true
- local plrs = {}
- for i, v in pairs(game.Players:GetPlayers()) do
- if v.Character then
- local gametag = Instance.new("StringValue",v.Character)
- gametag.Name = "GameTag"
- table.insert(plrs,v)
- local td = true
- local spawns = mapclone.Spawns:GetChildren()
- local chosen = spawns[math.random(1,#spawns)]
- v.Character:SetPrimaryPartCFrame(chosen.CFrame)
- v.Character.Humanoid.Died:Connect(function()
- if td == true then
- td = false
- if v.Character:FindFirstChild("GameTag") then
- v.Character.GameTag:Destroy()
- end
- end
- end)
- end
- end
- for i = gametime,1,-1 do
- status.Value = "Game in progress... "..i
- for i, v in pairs(plrs) do
- if v.Character then
- if v.Character:FindFirstChild("GameTag") then
- else
- table.remove(plrs,i)
- end
- else
- table.remove(plrs,i)
- end
- end
- if #plrs == plrstowin then
- status.Value = plrs[1].Name.." is the winner!"
- won = true
- plrs[1].leaderstats["Battle Bucks"].Value = plrs[1].leaderstats["Battle Bucks"].Value + money
- plrs[1].XP.Value = plrs[1].XP.Value + xp
- plrs[1].leaderstats.Wins.Value = plrs[1].leaderstats.Wins.Value + 1
- wait(3)
- for i, v in pairs(plrs) do
- if v.Character then
- v:LoadCharacter()
- end
- end
- mapclone:Destroy()
- for i, v in pairs(workspace:GetChildren()) do
- if v:FindFirstChild("Chest") then
- v:Destroy()
- end
- end
- game.ReplicatedStorage.Values.GameRunning.Value = false
- game.Lighting.ClockTime = 14
- break
- elseif #plrs == 0 then
- status.Value = "No one won!"
- wait(3)
- mapclone:Destroy()
- for i, v in pairs(workspace:GetChildren()) do
- if v:FindFirstChild("Chest") then
- v:Destroy()
- end
- end
- game.ReplicatedStorage.Values.GameRunning.Value = false
- game.Lighting.ClockTime = 14
- break
- end
- wait(1)
- end
- if won == false then
- status.Value = "No one won!"
- for i, v in pairs(plrs) do
- if v.Character then
- v:LoadCharacter()
- end
- end
- mapclone:Destroy()
- for i, v in pairs(workspace:GetChildren()) do
- if v:FindFirstChild("Chest") then
- v:Destroy()
- end
- end
- game.ReplicatedStorage.Values.GameRunning.Value = false
- game.Lighting.ClockTime = 14
- wait(3)
- else
- end
- else
- --display not enough players
- status.Value = minplrs.." or more players are required to start the game"
- end
- wait()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement