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

Can I make a block hurt one team and not the other?

Asked by 7 years ago

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.

0
can you add your current code? User#5423 17 — 7y

2 answers

Log in to vote
-2
Answered by 7 years ago

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)
0
the player will not always be the thing touching the part Volodymyr2004 293 — 7y
0
In that case it would return nil. IDidMakeThat 1135 — 7y
Ad
Log in to vote
0
Answered by
LuaXYZ 5
7 years ago

You can also do

if Player.Team == game.Teams.TeamName then
    --stuff
end

Answer this question