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

How do you make a weapon that only hurts one team?

Asked by 2 years ago

Is there any way to create a weapon which only hurts certain team? I'm just asking if it's complicated (and if it's not) how to do it. And if it's complicated, does anyone have a link to some article or tutorial on the topic?

1 answer

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

It's a single line, you just need 2 Players, both of them have Team property which says in which team they are, you need to compare player that shot the bullet or threw the rock's team with player who got hit's team, if they are in the same team, don't dare you damage him.

local player_that_attack = [...]
local player_that_got_hit = [...]

if player_that_attack.Team == player_that_got_hit.Team then
    print("u try to attack team member")
else
    print("kill this pig")
end

In order to check for a different team you can use the same method:

local Teams = game:GetService("Teams")

local target_team = Teams.[...]

if some_player.Team == target_team then
    print("Deal damage")
end
Ad

Answer this question