Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to add a random map picker and a spectate option for players who arent in the current game?

Asked by 8 years ago

local maps = game:GetService("ServerStorage"):WaitForChild("Maps"); local bomb = game:GetService("ServerStorage"):WaitForChild("Bomb");

local roundTime = 100;

local tracker = game:GetService("Workspace"):WaitForChild("Trackers"); local timer = tracker:WaitForChild("Timer"); local owner = tracker:WaitForChild("Owner");

local currentMap, currentBomb;

-- function

function pickMap() if currentMap then currentMap:Destroy(); end; local maps = maps:GetChildren(); currentMap = maps[math.random(#maps)]:Clone(); currentMap.Parent = game:GetService("Workspace"); currentMap:MakeJoints(); end;

function loadCharacters() local players = game:GetService("Players"):GetPlayers(); local bombGuy = players[math.random(#players)]; for _, player in pairs(players) do player:LoadCharacter(); end; if currentBomb then currentBomb:Destroy(); end; currentBomb = bomb:Clone(); currentBomb.Parent = bombGuy.Character; end;

function startTimer(t) while t > 0 and game:GetService("Players").NumPlayers >= 2 do wait(1); t = t - 1; timer.Value = t; end; end;

function declareLoser() local msg = Instance.new("Message", game:GetService("Workspace")); msg.Text = owner.Value.Name.." was the loser!"; wait(2); msg:Destroy(); end;

function initRound() pickMap(); loadCharacters(); startTimer(roundTime); declareLoser(); end;

-- run

wait(.2); while true do if game:GetService("Players").NumPlayers >= 2 then initRound(); else wait(); end; end;

Lol I tried to add one but Im not that good at scripting

1 answer

Log in to vote
-1
Answered by 8 years ago

bump

Ad

Answer this question