Hello developers! Me and my friend are currently trying to set up a mini-game in our game. The intention is to have a player (On the specified team) get teleported into the course solo and complete the course earning that team a single point. Upon earning a point the player will then be teleported out of the course and another player will teleport in his place and that’s how the cycle is.
We want the system to teleport a new player to not repeat any of the same players until they all have tried once, where it will go from the start again assuming no one has won. When me and my friend try it out it either teleports no one after his attempt or it teleports a 100% random player (Meaning lot’s of repeats by the same players). This is the code we’re going with for the moment but it’s not working the way we want and we are both stumped after trying to find a solution for a while. Any help is appreciated!
local TeamKalabaw = {}
for i, v in next, game.Teams.Kalabaw:GetPlayers() do
table.insert(TeamKalabaw, v)
end
if KalabawPoints == 10 then
--Team win label
elseif count > #TeamKalabaw then
count = 1
TeamKalabaw[count].Character:MoveTo(ToStart.Position)
else
TeamKalabaw[count].Character:MoveTo(ToStart.Position)
count = count + 1
end
We are only looking to teleport players on a specific team in order and one after another once they finish the course. There are multiple teams in the game and only players from that specific team are the ones we need.
We don’t need to cycle through all players using game.Players:GetPlayers() we need to cycle through a specific team (Kalabaw) which we used game.Teams.Kalabaw:GetPlayers() in a for loop for. The problem is getting the next player to teleport properly. (Example: If I start, it will teleport me again after completing, and then after a second time it will teleport my friend)
Teleporting as the player finishes yes. Let’s say the team has 10 players. 1 player will be teleported into the course and upon completing it he will be teleported out and another player will be teleported in. The game will let all 10 individual players compete once.
Okay we feel stupid now. The problem was just caused by “count = count + 1” being under the “TeamKalabaw[count].Character:MoveTo(ToStart.Position)”. We tried it out now and everything works like we intended! Remember to have lines in correct descending order!!