local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local Teams = game:GetService("Teams") local ServerStorage = game:GetService("ServerStorage") -- Create teams if they don't exist local SurvivorTeam = Teams:FindFirstChild("Survivors") or Instance.new("Team") SurvivorTeam.Name = "Survivors" SurvivorTeam.TeamColor = BrickColor.new("Bright blue") SurvivorTeam.AutoAssignable = true SurvivorTeam.Parent = Teams local KillerTeam = Teams:FindFirstChild("Killers") or Instance.new("Team") KillerTeam.Name = "Killers" KillerTeam.TeamColor = BrickColor.new("Bright red") KillerTeam.AutoAssignable = false KillerTeam.Parent = Teams -- Remote events local CoreEvent = Instance.new("RemoteEvent") CoreEvent.Name = "CoreEvent" CoreEvent.Parent = ReplicatedStorage local RoundState = "Waiting" -- Waiting, InProgress, Ended local RoundTime = 180 -- 3 minutes local SurvivorCount = 8 local KillerCount = 1 -- Spawn locations local SurvivorSpawns = workspace:FindFirstChild("SurvivorSpawns") local KillerSpawns = workspace:FindFirstChild("KillerSpawns") local function startRound() RoundState = "InProgress" -- Assign killer randomly local playersList = Players:GetPlayers() if #playersList < 2 then return end -- Pick a random killer local killerIndex = math.random(1, #playersList) local killer = playersList[killerIndex] killer.Team = KillerTeam -- Everyone else is survivor for _, player in pairs(playersList) do if player ~= killer then player.Team = SurvivorTeam end end -- Load characters for _, player in pairs(playersList) do player:LoadCharacter() task.wait(0.1) end -- Fire round start to all clients CoreEvent:FireAllClients("RoundStart", killer.Name, RoundTime) -- Round timer task.wait(RoundTime) if RoundState == "InProgress" then endRound("Survivors") -- Time's up, survivors win end end local function endRound(winningTeam) RoundState = "Ended" CoreEvent:FireAllClients("RoundEnd", winningTeam) task.wait(5) RoundState = "Waiting" -- Reset teams for _, player in Players:GetPlayers() do player.Team = nil end task.wait(3) startRound() end -- Detect when someone dies local function onPlayerCharacterAdded(player, character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() if RoundState ~= "InProgress" then return end -- Check if all survivors are dead local survivorsAlive = 0 for _, p in Players:GetPlayers() do if p.Team == SurvivorTeam and p.Character and p.Character:FindFirstChild("Humanoid") then local hum = p.Character:FindFirstChild("Humanoid") if hum and hum.Health > 0 then survivorsAlive = survivorsAlive + 1 end end end if survivorsAlive == 0 then endRound("Killers") end end) end for _, player in Players:GetPlayers() do player.CharacterAdded:Connect(function(char) onPlayerCharacterAdded(player, char) end) if player.Character then onPlayerCharacterAdded(player, player.Character) end end Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) onPlayerCharacterAdded(player, char) end) end) -- Start the first round when players join task.wait(5) startRound()