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

How do I team one random player to "Monster" without teaming before all five players join?

Asked by 5 years ago

I want to make a game where four players must run from one (player) monster while completing tasks. I want the selection of the monster to be random, so I used a bindable event to determine that the round starts when all five players join. The script, however does not work and nobody gets teamed. No errors are in the console.

local repStorage = game:GetService("ReplicatedStorage")
local event = repStorage:WaitForChild("RoundStart")
local players = game.Players:GetPlayers()

while true do
    if #players == 5 then
        event:Fire()
    end
    wait(.01)
end

Script that fires the event ^^^

local repStorage = game:GetService("ReplicatedStorage")
local event = repStorage:WaitForChild("RoundStart")

event.Event:Connect(function()
    local var = game.Players:GetPlayers()
    local monster = var[math.random(1, #var)]
    monster.TeamColor = BrickColor.new("Really red") --color of monster team
end)

Team script ^^^

0
If you are going to have a server player limit cap, you could replace #var with the cap number, so 6 local monster = var[math.random(1, 5)] WizyTheNinja 834 — 5y

Answer this question