This error comes up very inconsistently when a new round is being loaded in, ive left the game running for about 5 rounds until it happened, it seems to be random when it happens (sometimes after 1 round, others after a lot of rounds go by)
Problem is that though it is inconsistent, when it does happen it breaks the entire server as it stops the round being loaded in and the script progressing.
This is the part of the script:
Any help would be appreciated thanks as I do not know why it happens (and why when it does it only happens every now and then rather than everytime)
maybe remove the first table.remove line? (the one under teams knight)
1 Like
This solves this issue but stops the team selecting from working, the “pretender” team selecting still works but it stops anyone from being put on the “knight” team
can you give me the script so i can edit it?
local players = game.Players:GetPlayers()
if #Players:GetPlayers() >= 3 then
local index = math.random(1,#players) -- choose a random index between 1 and the length of the table
players[index].Team = teams["Knight"] -- set the randomly chosen player to the team
table.remove(players,index) -- removes them from the pool of players, ensuring no duplicate picking later
players[index].Team = teams["Pretender"] -- set the randomly chosen player to the team
table.remove(players,index) -- removes them from the pool of players, ensuring no duplicate picking later
end
local players = game.Players:GetPlayers()
if #Players:GetPlayers() >= 3 then
local index = math.random(1,#players)
local randomTeam = math.random(1,2)
if randomTeam == 1 then
players[index].Team = teams["Knight"]
elseif randomTeam == 2 then
players[index].Team = teams["Pretender"]
end
table.remove(players,index)
end
hope this work
i don’t really good at scripting sorry if it doesnt work lol
Unfortunately this has a similar issue where it puts a random player into one of the teams but not the other one, though this time it alternates between the working team
there only Knight and Pretender team in Teams?
local players = game.Players:GetPlayers()
local count = #players;
if count >= 3 then
local function pick()
local index = math.random(#players);
local picked = players[index];
table.remove(players, index);
return picked;
end;
pick().Team = teams['Knight'];
pick().Team = teams['Pretender'];
end;
1 Like
Theirs a third called “The King”, and a default team called “default” (for those who arent selected)
oh hey someone already did itt
Yeah, thanks for your effort though really appreciate it
Thanks for this, seems to work