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

how do I switch player's teams based on their game?

Asked by 6 years ago

so, i am trying to make a meeting/exams/class place, and i want to be able to assign people with their name. I have already tried this technique:

function setTeam(player, teamName) newPlayer.TeamColor = game.Teams[teamName].TeamColor if newPlayer.Character then

   end

end

setTeam(game.Players.epicly2000, "?Academy?") setTeam(game.Players.proimaaz153, "?Academy?")

if someone could help me with this problem, it'd be greatly appreciated. Thank you!

0
sorry, this was the code: epicly2000 5 — 6y
0
function setTeam(player, teamName) newPlayer.TeamColor = game.Teams[teamName].TeamColor if newPlayer.Character then end end epicly2000 5 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
--// Set up Variables
local academy = game:GetService("Teams").Academy

--// When player joins
game.Players.PlayerAdded:connect(function(player) -- when the player spawns
    player.CharacterAdded:connect(function(character)
        if player.Name == "epicly2000" then -- if their username is epicly2000
        player.Team = academy -- their team is set to academy
        end
    end)
end)

It seems the system you're attempting to use is overly complex, however I can't ensure the above will work as I haven't been able to test it.

0
Hmm @BouncingBrenda that code doesn't seem to work. I'll send it to you in the form I put it in: epicly2000 5 — 6y
0
local academy = game:GetService("Teams").Academy game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player.Name == "epicly2000" then player.Team = ?Academy? end end) end) epicly2000 5 — 6y
0
I put it in basically the exactly same way you did, yet it did not come out correctly. I'll keep researching for solutions. Thanks for your help! epicly2000 5 — 6y
0
Is the team in the teams section named "Academy" and exactly that? BouncingBrenda 44 — 6y
Ad

Answer this question