Been Making a game sort of like forsaken and I need to make a round system where a killer gets picked. I managed to make this round system but I’m unsure on how to make a killer picking system with a different spawn point. (I don’t want to quit this game so it’d be nice if someone helped)
Server Script:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local INTERMISSION_TIME = 5
local ROUND_TIME = 10
local MIN_PLAYERS = 2
local function TeleportPlayers(cFrame)
local players = Players:GetPlayers()
for i, player in players do
if not player.Character then continue end
player.Character:PivotTo(cFrame)
end
end
local function Countdown(duration)
for i=duration, 1, -1 do
workspace:SetAttribute("Clock", i)
task.wait(1)
end
end
local function Intermission()
print("INTERMISSION")
workspace:SetAttribute("Status", "Intermission")
TeleportPlayers(workspace.SpawnLocation.CFrame * CFrame.new(0, 2, 0))
Countdown(INTERMISSION_TIME)
end
local function RunGame(newMap)
print("GAME STARTED")
workspace:SetAttribute("Status", "Game")
TeleportPlayers(newMap.Spawn.CFrame)
Countdown(ROUND_TIME)
newMap:Destroy()
end
while true do
if #Players:GetPlayers() >= MIN_PLAYERS then
Intermission()
workspace:SetAttribute("Status", "Loading Map...")
local maps = ReplicatedStorage.Maps:GetChildren()
local randomMap = maps[math.random(#maps)]
local newMap = randomMap:Clone()
newMap.Parent = workspace.CurrentMap
task.wait(1)
RunGame(newMap)
else
print("WAITING FOR PLAYERS...")
workspace:SetAttribute("Status", "Waiting For Players.")
task.wait(1)
end
end
Local Script (For GUI)
local gui = script.Parent
local function UpdateStatus()
local clockTime = workspace:GetAttribute("Clock")
local gameStatus = workspace:GetAttribute("Status")
if gameStatus == "Game" or gameStatus == "Intermission" then
gui.Label.Text = gameStatus .. ": " .. clockTime
else
gui.Label.Text = gameStatus
end
end
workspace:GetAttributeChangedSignal("Clock"):Connect(UpdateStatus)
workspace:GetAttributeChangedSignal("Status"):Connect(UpdateStatus)
UpdateStatus()