So basically I want to change the player’s team in the server based on what character they chose during the intermission.
I put a for loop to loop through all of the players. First, it will detect if the player hasn’t chosen a character and wait for them to choose one. (It should be impossible if they don’t, but just in case.) Then it will change the player’s team to what they chose. I also put in a separate script to automatically reset the player on team change.
Here is the script I used. I might add more because I’m not finished with it:
for i, v in pairs(players:GetChildren()) do
status.Value = "Game starting..."
if v.Backpack.CharacterChosen == "" then
status.Value = "Error: Everybody must choose a character."
repeat wait() until v.Backpack.CharacterChosen ~= ""
end
v.Team = game.Teams[v.Backpack.CharacterChosen] -- Error here
end
It returns an error saying it expected a string for the team, but got an instance instead.
So basically “v.Backpack.CharacterChosen” is equal to the team I want to put the player in, but it wants me to put a string. How can I do that?