Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a block change all players teams when a player from a specific team touches it?

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.

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

9 comments

0

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

0

Try BrickColor.new(“White”) instead

0

On what line? The last one instead of PLayer.TeamColor?

0

put this at line 7 instead : Player.TeamColor = BrickColor.new(“White”)

0

That new line seems to work but the script still gives me the error: players is not a valid member of DataModel

0

Oh I’m so sorry bro I just realized replace players with Player

0

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.

0

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

0

at least u eventually fixed my script lol please accept my answer since it provided what u wanted

This discussion is preserved as it was. New answers, comments, and votes are closed.