Relational operators
A relational operator is something that returns a boolean value based on the relationship between both it's operands. You can read about all the relational operators on the wiki here. What you're looking for, is the not-equal-to operator, which looks like this: ~= (in Lua).
Not-equal-to
The not-equal-to operator is pretty self-explanatory. It will return true only if both it's operands are not equal to one another. For example, print(1 ~= 2) would yield true, since 1 does not equal 2. The solution to your problem would be identical:
if p.Team ~= game.Teams.soldier then
return
end
There's also the not operator, which is similar in terms of returning the opposite of it's inequality. It's not what you'd need for this situation, but if you'd like to know more about it you can check out my old answer on it here.
Edit
As Goulstem mentioned, Team is now a member of each player which represents their team directly. The need to compare team colors to find out which team the player is on is now obsolete.
1 comment
~= means not equal. http://wiki.roblox.com/index.php?title=Conditional_statement#If