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

This script won't change player team or do the intermission system. why?

Asked by 4 years ago
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local teamBlue = Teams.Blue
local teamRed = Teams.Red
local teamSpectators = Teams.NotPlaying
local roundLength = 200
local intermissionLength = 60
local preload = 5
local count = game.ReplicatedStorage.Count
local stopped = workspace.Barrier
local LobbySpawn = game.Workspace.LobbySpawn
local GameAreaSpawn = game.Workspace.GameAreaSpawn

local function onPlayerDied(player, character)
    player.Team = teamSpectators
    local id = player:GetUserIdFromNameAsync()
    player.Character = id
    player.CharacterAppearanceId = id
    player:LoadCharacter()
end


local function play(player)
    -- Set the player's team using one of the following:
    local teamm = {teamBlue, teamRed}
    local index = math.random(1,#teamm)
    local playerR = teamm[teamRed]:GetPlayers()
    local playerB = teamm[teamBlue]:GetPlayers()
    local placement = teamm[index]
    player.Team = placement
    if #playerB < #playerR then 
        player.Team = teamm[teamBlue]
    elseif #playerB > #playerR then
        player.Team = teamm[teamRed]
    end 
    player:LoadCharacter()  
end

InRound.Changed:Connect(function()
    wait(1)
    if InRound.Value == true then
        for _, player in pairs(game.Players:GetChildren()) do
            play()
        end
    else
        for _, player in pairs(game.Players:GetChildren()) do
            onPlayerDied()
        end
    end
end)

function keep()
    if count.Value == 0 then
        stopped.CanCollide = false
        stopped.Transparency = 1
    elseif count.Value < 0 then
        stopped.CanCollide = true
        stopped.Transparency = 0
    end
end

local function roundTimer()
    while wait() do
        for i = intermissionLength, 1, -1 do
            InRound.Value = false
            wait(1)
            Status.Value = "Intermission: ".. i .." seconds left!"
        end
        for i = roundLength, 1, -1 do
            InRound.Value = true
            wait(1)
            Status.Value = "Game: ".. i .." seconds left!"
        end
    end
end
0
What exactly do you want? ScarletHypernova -5 — 4y
0
If there is a problem not letting the player change team do you have an error on the output window showing up so we see the line of the error? Dfzoz 489 — 4y
0
I rewrote the script qwertyuiopasdfghhh 13 — 4y

Answer this question