So, I wanted the script to call the function's ChangeTeam and Lobby but it won't call those two functions. I'm totally confused.
IntermissionTime = 10 RoundTime = 60 IntermissionString = "Intermission: %s" -- can be any string, put %s where you want the time to be displayed RoundString = "Time Left: %s" -- can be any string, put %s where you want the time to be displayed GetTime = Instance.new("RemoteFunction") GetTime.Name = "GetTime" GetTime.Parent = game.Workspace function GetTime.OnServerInvoke() local T = {} table.insert(T, String) table.insert(T, CurrentTime) return T end function CountTime() while CurrentTime > 0 do wait(1) CurrentTime = CurrentTime -1 end end function ChangeTeam() local currentPlayers = game.Players:GetPlayers() --Collect all players local currentTeams = game.Teams:GetChildren() --Collect all teams --Get a random player, and a random team local randomPlayer = currentPlayers[math.random(1,#currentPlayers)] local randomTeam = currentTeams[math.random(1,#currentTeams)] randomPlayer.Team = randomTeam end function Lobby() local currentPlayers = game.Players:GetPlayers() --Collect all players local currentTeams = game.Teams.BattleGofLobby --Collect all teams local Lobby = currentTeams currentPlayers.Team = Lobby end while wait() do String = IntermissionString Lobby() CurrentTime = IntermissionTime CountTime() String = RoundString ChangeTeam() CurrentTime = RoundTime CountTime() end
Lobby
doesn't do anything. You assign a specific team to the table of players you have. This doesn't assign each player in the list to the team, it just makes a new field in the table.
Instead, use a for
loop:
for _, player in ipairs(currentPlayers) do player.Team = Lobby end
Note that your ChangeTeam
function does little better -- it assigns a random team to a single player. You should at least do that for every player; you may also want to try to balance the teams (if a team has more players than another team, don't put more players on it).