Im trying to make it so that when the game starts, a random player is chosen to have the bomb, how would I be able to pick a random player, and how would I be able to randomize who has the bomb in the game next for whenever someone dies if they have the bomb?
To pick a random player, you could do something similar using math.random…
local function RandomPick()
local players = game:GetService:("Players"):GetPlayers()
local p = (players[math.random(1, #players)])
p -- do stuff to picked player
end
If you want to add the players with the bomb to a table you add something like…
local PlayerInTable = false
for _,OtherPlayer in next, PlayersWithBomb do
if OtherPlayer == Player then
PlayerInTable = true
end
end
if not PlayerInTable then
table.insert(PlayersWithBomb, Player)
end