Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. --Services
  2. local rep = game:GetService("ReplicatedStorage")
  3. local plrs = game:GetService("Players")
  4.  
  5. --Variables -- Defines where a place is easier
  6. local kspawn = workspace:WaitForChild("KillerSpawn")
  7. local sspawn = workspace:WaitForChild("SurvivorSpawns")
  8. local request
  9. local gametime = 500 -- How long the game will last
  10. local waitingtime = 5 -- How long the game takes before starting
  11.  
  12. --Tables
  13. local playersInMatch = {}
  14. local playersInLobby = {}
  15.  
  16. --Remotes
  17. local remotes = game.ReplicatedStorage:WaitForChild("Remotes")
  18. local countdown = remotes:WaitForChild("CountDown")
  19.  
  20. --plr
  21. game.Players.PlayerAdded:Connect(function(plr)
  22. table.insert(playersInLobby, plr.Name)--adds player to lobby table
  23. local inGame = Instance.new("BoolValue", plr)--Creates bool value so we can know if they are inmatch or inlobby
  24. plr.CharacterAdded:Wait()--Waits for character to load
  25. plr.Character.Humanoid.Died:Connect(function()
  26. if plr.inGame.Value == true then
  27. inGame.Value = false
  28. for i,v in pairs(playersInMatch) do
  29. if v == plr.Name then
  30. wait()
  31. table.remove(playersInMatch, plr.Name)
  32. end
  33. table.insert(playersInLobby, plr.Name)
  34. end
  35. end
  36. end)
  37. while wait(0.1) do
  38. if(#playersInMatch == 0) then
  39. request = "StartCountDown"
  40. for Num = waitingtime, 0-1 do
  41. countdown:FireAllClients(request, Num)
  42. end
  43. end
  44. end
  45. end)
  46.  
  47.  
  48.  
  49. --Functions
  50. function FindIndex(Table,Val)
  51. for index,v in pairs(Table) do
  52. if v == Val then
  53. return index
  54. end
  55. end
  56. end
  57.  
  58.  
  59. --Main
  60. while wait() do
  61. if#plrs:GetPlayers() >= 2 then
  62. request = "StartCountDown"
  63. for Num = waitingtime, 0,-1 do
  64. countdown:FireAllClients(request,Num)
  65. wait(1)
  66. end
  67.  
  68. local allplayers = {}
  69. for i,plr in pairs(plrs:GetPlayers()) do
  70. table.insert(allplayers,plr)
  71. end
  72.  
  73. local killer = allplayers[math.random(#allplayers)]
  74. table.remove(allplayers,FindIndex(allplayers,killer))
  75.  
  76. --Teleport
  77. killer.Character:SetPrimaryPartCFrame(kspawn.Spawn.CFrame + Vector3.new(0,3,0))
  78. local knife = game.ReplicatedStorage:WaitForChild("Knife"):Clone()
  79. knife.Parent = killer.Backpack
  80. killer.Character.Humanoid.WalkSpeed = 6
  81.  
  82. for i,plr in pairs(allplayers) do
  83. table.insert(playersInMatch, plr.Name)
  84. table.remove(playersInLobby, plr.Name)
  85. plr.InGame.Value = true
  86. local char = plr.Character or plr.CharacterAdded:Wait()
  87. local number = math.random(1,9)
  88. local oof = sspawn:FindFirstChild("Spawn"..number)
  89. char.HumanoidRootPart.CFrame = oof.CFrame + Vector3.new(0,3,0)
  90. char.Humanoid.WalkSpeed = 5.8
  91. end
  92.  
  93. request = "CountDown"
  94. for Num = gametime,0,-1 do
  95. countdown:FireAllClients(request,Num)
  96. wait(1)
  97. end
  98. for i,plr in pairs(allplayers) do
  99. plr.Character.Humanoid.Health = 0
  100. killer.Character.Humanoid.Health = 0
  101. end
  102. end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement