Here is an example script of me trying to make a simple cointoss:
local AllTeams = {"Red Team", "Blue Team", "Orange Team", "Purple Team", "White Team"} local randomteam1 = AllTeams[math.random(#AllTeams)] local randomteam2 = AllTeams[math.random(#AllTeams)] --This is what i wanted to do but you cant do this-- local CoinToss = {randomteam1, randomteam2} local CoinTossWinner = CoinToss[math.random(#CoinToss)] --How can I do this??
What this does is picks 2 random teams out of the "All Teams" table and what i wanted it to do after that, was I wanted it to pick a random variable so it could be like a coin toss, sadly i dont know how to do this
Any feedback is helpful, thanks.
local teams = {"Team1", "Team2", "Team3", "Team4", "Team5"} local randomTeam = teams[math.random(1, #teams)] local randomTeam2 = teams[math.random(1, #teams)] if randomTeam ~= randomTeam2 then -- make sure the number isn’t the same coinToss = {randomTeam, randomTeam2} local winner = coinToss[math.random(1, #coinToss)] print(winner) --will print your winner end