I am new to scripting and I have been trying to find an answer to this question but nothing that works has come up. I have 3 teams named Maroons, Deep Oranges and Lobby. I am wanting to make a game where the player from the Maroons team has to touch a block and then the block which is called EndBlock will change all players teams back to Lobby, kill them and then display a gui. I have tried to use a function which is function onTouched() but I don't know how to make the player switch teams. I should be able to script the kill and the gui part just don't understand the changing teams part.
✓ ANSWER ACCEPTED
How to make a block change all players teams when a player from a specific team touches it?
1 answer
✓ Accepted answer
I thought modified spawnlocations do that but if u really want to get a well functioning one try this script :
local Part = script.Parent
Part.Touched:Connect(function(hit)
local Player = game.players:FindFirstChild(hit.Parent.Name)
if not Player then return end
Player.Team = game.Teams.Maroon -- Team instance inside of the Teams service
Player.TeamColor = -- The BrickColor of the team like Maroon
end)
Try one or the other method Remember to put the script inside of the Part
This discussion is preserved as it was. New answers, comments, and votes are closed.

9 comments
I pasted it in and when I put in White for the team colour on the line 7 and it has the blue underline saying that unknown global White. I have also tried putting quotation marks around it and it gets rid of the underline but when i run it with the quotation marks, it says that players is not a valid member of DataModel
Try BrickColor.new(“White”) instead
On what line? The last one instead of PLayer.TeamColor?
put this at line 7 instead : Player.TeamColor = BrickColor.new(“White”)
That new line seems to work but the script still gives me the error: players is not a valid member of DataModel
Oh I’m so sorry bro I just realized replace players with Player
It worked and I didn't do the change you said above. Also does changing it to Player means it only does one player, because I am trying to make it the whole server.
I just re wrote it myself and it fixed it. I do this sometimes if I ever copy and paste something and it doesn't work
at least u eventually fixed my script lol please accept my answer since it provided what u wanted