I need help fixing my anti team kill script inside of my tool it is a serverscript
it works it’s just not finding the teams everything prints fine but i still damage my own teammate… can someone help?
local teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(teams) do
local players = team:GetPlayers()
if game.Teams.Empire then
local Character = players
EnemyHumanoid:TakeDamage(Tool.Values.Damage.Value)
print("EnemyFound")
if game.Teams.Republic then
local Character = players
EnemyHumanoid:TakeDamage(Tool.Values.Damage.Value == 0)
print("Teammate")
end
end
game.ReplicatedStorage.RemoteEvents.Music:FireClient(player)
end
end
end)
I believe the root of the problem is that you aren’t checking the enemy’s team. You go through all of the teams but don’t check the enemy’s team. It would help if I could see where you define “EnemyHumanoid”, but this is the best I can provide with the current information:
if game.Players:GetPlayerFromCharacter(EnemyHumanoid.Parent).Team == game.Teams.Empire then
EnemyHumanoid:TakeDamage(Tool.Values.Damage.Value)
end
Also, only use this for the tools of the “Republic” team (it won’t work and you will only be able to damage teammates otherwise)
Hey how would I let it attack a npc and that team? would it be nvm this won’t work how would i do it?
if game.Players:GetPlayerFromCharacter(EnemyHumanoid.Parent).Team == game.Teams.Empire
then
EnemyHumanoid:TakeDamage(Tool.Values.Damage.Value)
if not game.Players:GetPlayerFromCharacter(EnemyHumanoid.Parent).Team ==
game.Teams.Empire then
EnemyHumanoid:TakeDamage(Tool.Values.Damage.Value)
end