Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- local status = game.ReplicatedStorage:WaitForChild("Status")
- function module.Intermission(length)
- for i = length,0,-1 do
- status.Value = "Next round starts in "..i.." seconds"
- wait(1)
- end
- end
- function module.SelectChapter()
- local rand = Random.new()
- local chapters = game.ReplicatedStorage.Chapters:GetChildren()
- local chosenChapter = chapters[rand:NextInteger(1,#chapters)]
- return chosenChapter
- end
- function module.ChoosePiggy(players)
- local RandomObj = Random.new()
- local chosenPiggy = players[RandomObj:NextInteger(1,#players)]
- return chosenPiggy
- end
- function module.DressPiggy(piggy)
- local character = game.ServerStorage.Piggy:Clone()
- character.Name = piggy.Name
- piggy.Character = character
- character.Parent = workspace
- end
- function module.TeleportPiggy(player)
- if player.Character then
- player.Character.Humanoid.WalkSpeed = 14
- local bat = game.ServerStorage.Tools.PiggyBat:Clone()
- bat.Parent = player.Character
- if player.Character:FindFirstChild("HumanoidRootPart") then
- player.Character.HumanoidRootPart.CFrame = game.Workspace.WaitingRoom.PiggyWaitingSpawn.CFrame + Vector3.new(0,5,0)
- end
- local TrapCount = Instance.new("IntValue")
- TrapCount.Name = "TrapCount"
- TrapCount.Value = 5
- TrapCount.Parent = player
- game.ReplicatedStorage.ToggleTrap:FireClient(player,true)
- end
- end
- function module.TeleportPlayers(players,mapSpawns)
- for i,player in pairs(players) do
- if player.Character then
- local character = player.Character
- if character:FindFirstChild("HumanoidRootPart") then
- player.Character.Humanoid.WalkSpeed = 16
- local rand = Random.new()
- player.Character.HumanoidRootPart.CFrame = mapSpawns[rand:NextInteger(1,#mapSpawns)].CFrame + Vector3.new(0,10,0)
- local hitboxClone = game.ServerStorage.Hitbox:Clone()
- hitboxClone.CFrame = character.HumanoidRootPart.CFrame
- local weld = Instance.new("Weld")
- weld.Part1 = character.HumanoidRootPart
- weld.Part0 = hitboxClone
- weld.Parent = character
- hitboxClone.Parent = player.Character
- end
- end
- end
- end
- function module.InsertTag(contestents, tagName)
- for i, player in pairs(contestents) do
- local Tag = Instance.new("StringValue")
- Tag.Name = tagName
- Tag.Parent = player
- end
- end
- local function toMS(s)
- return ("%02i:%02i"):format(s/60%60, s%60)
- end
- function module.StartRound(length,piggy,chapterMap)
- local outcome
- game.ServerStorage.GameValues.GameInProgress.Value = true
- for i = length,0,-1 do
- if i == (length - 20) then
- module.TeleportPlayers({piggy},chapterMap.PlayerSpawns:GetChildren())
- status.Value = "Piggy has woken up!"
- wait(2)
- end
- local contestents = {}
- local isPiggyHere = false
- local Escapees = 0
- for i, player in pairs(game.Players:GetPlayers()) do
- if player:FindFirstChild("Contestant") then
- table.insert(contestents,player)
- elseif player:FindFirstChild("Piggy") then
- isPiggyHere = true
- end
- if player:FindFirstChild("Escaped") then
- Escapees = Escapees + 1
- end
- end
- status.Value = toMS(i)
- if Escapees > 0 then
- outcome = "escaped"
- break
- end
- if not isPiggyHere then
- outcome = "piggy-left"
- break
- end
- if #contestents == 0 then
- outcome = "piggy-killed-everyone"
- break
- end
- if i == 0 then
- outcome = "time-up"
- break
- end
- wait(1)
- end
- if outcome == "piggy-left" then
- status.Value = "Piggy Has Died / Left, Contestents Win!"
- elseif outcome == "piggy-killed-everyone" then
- status.Value = "The Piggy Has Killed Everyone. Piggy Wins!"
- elseif outcome == "time-up" then
- status.Value = "Times Up! Contestents Win!"
- elseif outcome == "escaped" then
- status.Value = "Contestents Have Escaped! Piggy Loses!"
- end
- wait(5)
- end
- function module.RemoveTags()
- game.ServerStorage.GameValues.GameInProgress.Value = false
- game.ReplicatedStorage.ToggleCrouch:FireAllClients(false)
- for i, v in pairs(game.Players:GetPlayers()) do
- if v:FindFirstChild("Piggy") then
- v.Piggy:Destroy()
- if v.Backpack:FindFirstChild("PiggyBat") then v.Backpack.PiggyBat:Destroy() end
- if v.Character:FindFirstChild("PiggyBat") then v.Character.PiggyBat:Destroy() end
- if v:FindFirstChild("TrapCount") then
- v.TrapCount:Destroy()
- end
- game.ReplicatedStorage.ToggleTrap:FireClient(v,false)
- v:LoadCharacter()
- elseif v:FindFirstChild("Contestant") then
- v.Contestant:Destroy()
- for _,p in pairs(v.Backpack:GetChildren()) do
- if p:IsA("Tool") then
- p:Destroy()
- end
- end
- for _,p in pairs(v.Character:GetChildren()) do
- if p:IsA("Tool") then
- p:Destroy()
- end
- end
- end
- if v:FindFirstChild("Escaped") then
- v.Escaped:Destroy()
- end
- end
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment