Hello, I’m trying to do something where if you are trying to kill someone, it checks to see if they are on the same team or not. If they are, it prints “Friendly Fire.” If they are not on the same team, it takes damage to the person who gets shoot. But it’s not working. No prints in the output, and no errors in the output. How can I fix this problem?
Script:
function hitDetection(hit,ray, mousepos)
local model = hit:FindFirstAncestorOfClass("Model")
local the_player = game.Players:GetPlayerFromCharacter(character)
local the_player_2 = game.Players:GetPlayerFromCharacter(model)
if model then
local humanoid = model:FindFirstChildWhichIsA("Humanoid")
if humanoid then
if hit.Name == "Head" then
if the_player.Team ~= the_player_2 then
humanoid:TakeDamage(configuration.HeadShotDamage)
untag_Player(humanoid)
tag_Player(the_player, humanoid)
if humanoid.Health <= 0 then
end
elseif the_player.Team == the_player_2.Team then
print("Friendly Fire!")
end
else
if the_player.Team ~= the_player_2 then
humanoid:TakeDamage(configuration.Damage)
untag_Player(humanoid)
tag_Player(the_player, humanoid)
if humanoid.Health <= 0 then
end
elseif the_player.Team == the_player_2.Team then
print("Friendly Fire!")
end
end
else
return true
end
end
end
If you need the full script, let me know. Help soon,