How to check if a player isn't on a team?

Hey, I am making a combat system want to know how I would go around checking if a player and the target player are not on a team. Any guidance is appreciated!

You could use the ~= operator which means not equal to.
By comparing the .Team properties of the local and target player, you can check if they’re on the same team or not. You can read more about operators here.

if PlayerA.Team ~= PlayerB.Team then 
-- Do stuff

You could just find what team the player is on via the .Team properity of the player and then compare it to the other player. What @E7LK put should be correct.

Is it fine if i just use == and put what you suggested in an else statement?

Do you mean…

if not PlayerA.Team == PlayerB.Team then
-- do stuff

If you do mean that, then it will work but I recommend using ~= to make your script more readable.

or do you mean…

if PlayerA.Team == PlayerB.Team then



because that will work fine.

I mean to use the second one. Thanks for letting me know

1 Like