This is the "brain" of your game. Add it to ServerScriptService:
-- CHAMBER OF SECRETS - Main Game Script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Game settings
local MIN_PLAYERS = 2
local COUNTDOWN_TIME = 5
local CHASE_TIME = 30
-- Game state
local gameRunning = false
local parseltonguePlayer = nil
local basilisk = workspace:WaitForChild("Basilisk")
-- Values for clients to see
local gameStatus = Instance.new("StringValue")
gameStatus.Name = "GameStatus"
gameStatus.Value = "Waiting for players..."
gameStatus.Parent = ReplicatedStorage
local timerValue = Instance.new("IntValue")
timerValue.Name = "GameTimer"
timerValue.Value = 0
timerValue.Parent = ReplicatedStorage
-- Pick random player
local function pickParseltongue()
local allPlayers = Players:GetPlayers()
if #allPlayers < MIN_PLAYERS then
return nil
end
local chosen = allPlayers[math.random(1, #allPlayers)]
return chosen
end
-- Start the game
local function startGame()
gameRunning = true
-- Pick the secret player
parseltonguePlayer = pickParseltongue()
if not parseltonguePlayer then
gameStatus.Value = "Need more players!"
return
end
print("Parseltongue is: " .. parseltonguePlayer.Name)
-- Countdown
gameStatus.Value = "Get ready!"
for i = COUNTDOWN_TIME, 1, -1 do
timerValue.Value = i
wait(1)
end
gameStatus.Value = "Parseltongue can now command the snake!"
-- The game continues from here...
-- (You'll add the chase and voting parts!)
end
-- Wait for players, then start
while true do
if #Players:GetPlayers() >= MIN_PLAYERS and not gameRunning then
wait(5)
startGame()
end
wait(1)
end This script gives you the basic structure. You'll need to:
Every great game needs a great map! Here are some ideas: