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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
St_vnC 330 Moderation Voter
4 years ago

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

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 electrocat56 18 — 4y
0
Try BrickColor.new(“White”) instead St_vnC 330 — 4y
0
On what line? The last one instead of PLayer.TeamColor? electrocat56 18 — 4y
0
put this at line 7 instead : Player.TeamColor = BrickColor.new(“White”) St_vnC 330 — 4y
View all comments (5 more)
0
That new line seems to work but the script still gives me the error: players is not a valid member of DataModel electrocat56 18 — 4y
0
Oh I’m so sorry bro I just realized replace players with Player St_vnC 330 — 4y
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. electrocat56 18 — 4y
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 electrocat56 18 — 4y
0
at least u eventually fixed my script lol please accept my answer since it provided what u wanted St_vnC 330 — 4y
Ad

Answer this question