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.
✓ ANSWER ACCEPTED
Can I make a block hurt one team and not the other?
2 answers
✓ Accepted answer
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)
2 comments
0
the player will not always be the thing touching the part
0
In that case it would return nil.
You can also do
if Player.Team == game.Teams.TeamName then
--stuff
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
can you add your current code?