Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 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. while wait(0.1) do
  37. if(#playersInMatch == 0) then
  38. request = "StartCountDown"
  39. for Num = waitingtime, 0-1 do
  40. countdown:FireAllClients(request, Num)
  41. end
  42. end
  43. end
  44. end)
  45. end)
  46. --Functions
  47. function FindIndex(Table,Val)
  48. for index,v in pairs(Table) do
  49. if v == Val then
  50. return index
  51. end
  52. end
  53. end
  54.  
  55. --Main
  56. while wait() do
  57. if#plrs:GetPlayers() >= 2 then
  58. request = "StartCountDown"
  59. for Num = waitingtime, 0,-1 do
  60. countdown:FireAllClients(request,Num)
  61. wait(1)
  62. end
  63.  
  64. local allplayers = {}
  65. for i,plr in pairs(plrs:GetPlayers()) do
  66. table.insert(allplayers,plr)
  67. print("Player: "..plr.Name)
  68. end
  69.  
  70. local killer = allplayers[math.random(#allplayers)]
  71. table.remove(allplayers,FindIndex(allplayers,killer))
  72. --Teleport
  73. killer.Character:SetPrimaryPartCFrame(kspawn.Spawn.CFrame + Vector3.new(0,3,0))
  74. local knife = game.ReplicatedStorage:WaitForChild("Knife"):Clone()
  75. knife.Parent = killer.Backpack
  76. killer.Character.Humanoid.WalkSpeed = 6
  77.  
  78.  
  79. for i,plr in pairs(allplayers) do
  80. table.insert(playersInMatch, plr.Name)
  81. table.remove(playersInLobby, plr.Name)
  82. plr.InGame.Value = true
  83. local char = plr.Character or plr.CharacterAdded:Wait()
  84. local number = math.random(1,7)
  85. local oof = sspawn:FindFirstChild("Spawn"..number)
  86. char.HumanoidRootPart.CFrame = oof.CFrame + Vector3.new(0,3,0)
  87. char.Humanoid.WalkSpeed = 5.8
  88. end
  89.  
  90. request = "CountDown"
  91. for Num = gametime,0,-1 do
  92. countdown:FireAllClients(request,Num)
  93. wait(1)
  94. end
  95.  
  96. for i,plr in pairs(allplayers) do
  97. plr.Character.Humanoid.Health = 0
  98. killer.Character.Humanoid.Health = 0
  99. end
  100. end
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement