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
end
2 Likes
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
end
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
else
end
because that will work fine.
I mean to use the second one. Thanks for letting me know
1 Like