Can i make it possible for people in the same team to kill each other?

hello everyone, how can i make it so that people in the same team can kill each other? Because i’m creating a game and when people go to the team to fight, they can’t kill each other, what can i do?

1 Like

Hey! We’d need to see some of the code to understand what’s going on further here. Please also note this should be in the #help-and-feedback:scripting-support section as this is 99% scripting related! :slight_smile:

Before damaging, check if both players are on the same team. If they are, don’t deal any damage. You can use the player’s Team property for this. You’ll also need a way to get both players.

Crude sample:

if player.Team.Name == otherPlayer.Team.Name then return end
otherHumanoid:TakeDamage(50)
1 Like

thanks, but what i mean is that people who are in the same team can harm each other with weapons.

Check if the player (weapon wearer)'s team equality to the target player’s team. If they aren’t equal, find the target’s humanoid and take damage if found. If both players are in the same team, just skip the process.

if player.Team.Name ~= target.Team.Name then
    local humanoid = target:FindFirstChild("Humanoid")
    if humanoid then
        humanoid:TakeDamage(50)
    end
end

If you want teammates to fight eachother under certain conditions, check for that in the condition like player.Team.Name ~= target.Team.Name or checkTeamKillPerm(player, target).

You can reverse the condition by adding a “not” at the beginning then. You will have to enclose the condition in brackets though, otherwise the not will only apply to the left-side operand.

if not (player.Team.Name == otherPlayer.Team.Name) then return end
otherHumanoid:TakeDamage(50)

Not equal also works: take the same original code sample I provided but use ~= instead.

1 Like