I have been trying to find out how to make a block hurt one team and leave the other unharmed. I have spent months trying to figure this out with no luck. as for the code I used I haven't even the slightest clue about using teams in a script. I'm sorry if this seems a bit sloppy but I had never really been good with writing.
You can find out what team a player is on by using the TeamColor
property of the player. For example, if you had two teams, one being Bright blue and the other Bright yellow, putting this script in a brick would make it only damage players on the Bright blue team:
script.Parent.Touched:connect(function(hit) local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player and Player.TeamColor == BrickColor.new("Bright blue") then hit.Parent.Humanoid:TakeDamage(20) end end)
You can also do
if Player.Team == game.Teams.TeamName then --stuff end