Is it possible to add Anti Team Kill into a gun? If possible, how?

So, I am trying to add Anti-Team kill into the game. But, how can I do it?

		if L_217_ then
			local L_229_, L_230_ = CheckForHumanoid(L_217_)
			if L_229_ then
				L_111_:FireServer(L_230_)
				if L_24_.AntiTK then
					if game.Players:FindFirstChild(L_230_.Parent.Name) and game.Players:FindFirstChild(L_230_.Parent.Name).TeamColor ~= L_2_.TeamColor or L_230_.Parent:FindFirstChild('Vars') and game.Players:FindFirstChild(L_230_.Parent:WaitForChild('Vars'):WaitForChild('BotID').Value) and L_2_.TeamColor ~= L_230_.Parent:WaitForChild('Vars'):WaitForChild('teamColor').Value then
						if L_217_.Name == 'Head' then
							L_110_:FireServer(L_230_, L_24_.HeadDamage)
							local L_231_ = L_19_:WaitForChild('BodyHit'):clone()
							L_231_.Parent = L_2_.PlayerGui
							L_231_:Play()
							game:GetService("Debris"):addItem(L_231_, L_231_.TimeLength)
						end
						if L_217_.Name ~= 'Head' and not (L_217_.Parent:IsA('Accessory') or L_217_.Parent:IsA('Hat')) then
							if L_217_.Name ~= 'Torso' and L_217_.Name ~= 'HumanoidRootPart' and L_217_.Name ~= 'Armor' then
								L_110_:FireServer(L_230_, L_24_.LimbDamage)
							elseif L_217_.Name == 'Torso' or L_217_.Name == 'HumanoidRootPart' and L_217_.Name ~= 'Armor'  then
								L_110_:FireServer(L_230_, L_24_.BaseDamage)
							elseif L_217_.Name == 'Armor' then
								L_110_:FireServer(L_230_, L_24_.ArmorDamage)
							end
							local L_232_ = L_19_:WaitForChild('BodyHit'):clone()
							L_232_.Parent = L_2_.PlayerGui
							L_232_:Play()
							game:GetService("Debris"):addItem(L_232_, L_232_.TimeLength)
						end
						if (L_217_.Parent:IsA('Accessory') or L_217_.Parent:IsA('Hat')) then
							L_110_:FireServer(L_230_, L_24_.HeadDamage)
							local L_233_ = L_19_:WaitForChild('BodyHit'):clone()
							L_233_.Parent = L_2_.PlayerGui
							L_233_:Play()
							game:GetService("Debris"):addItem(L_233_, L_233_.TimeLength)
						end
					end
				else
					if L_217_.Name == 'Head' then
						L_110_:FireServer(L_230_, L_24_.HeadDamage)
						local L_234_ = L_19_:WaitForChild('BodyHit'):clone()
						L_234_.Parent = L_2_.PlayerGui
						L_234_:Play()
						game:GetService("Debris"):addItem(L_234_, L_234_.TimeLength)
					end
					if L_217_.Name ~= 'Head' and not (L_217_.Parent:IsA('Accessory') or L_217_.Parent:IsA('Hat')) then
						if L_217_.Name ~= 'Torso' and L_217_.Name ~= 'HumanoidRootPart' and L_217_.Name ~= 'Armor' then
							L_110_:FireServer(L_230_, L_24_.LimbDamage)
						elseif L_217_.Name == 'Torso' or L_217_.Name == 'HumanoidRootPart' and L_217_.Name ~= 'Armor' then
							L_110_:FireServer(L_230_, L_24_.BaseDamage)
						elseif L_217_.Name == 'Armor' then
							L_110_:FireServer(L_230_, L_24_.ArmorDamage)
						end
						local L_235_ = L_19_:WaitForChild('BodyHit'):clone()
						L_235_.Parent = L_2_.PlayerGui
						L_235_:Play()
						game:GetService("Debris"):addItem(L_235_, L_235_.TimeLength)
					end
					if (L_217_.Parent:IsA('Accessory') or L_217_.Parent:IsA('Hat')) then
						L_110_:FireServer(L_230_, L_24_.HeadDamage)
						local L_236_ = L_19_:WaitForChild('BodyHit'):clone()
						L_236_.Parent = L_2_.PlayerGui
						L_236_:Play()
						game:GetService("Debris"):addItem(L_236_, L_236_.TimeLength)
					end
				end	
			end
		end
	
		if L_217_ and L_217_.Parent:FindFirstChild("Humanoid") then
			return L_217_, L_218_;
		end
		L_220_ = L_221_;
	end
end

[Not Full Part] My Damage Script ^ ^

once the bullet hits you can use game.Players:GetPlayerFromCharacter() to get the player object then just check if the team is not the same as yours then damage

2 Likes

Okay let me go try it out! Thanks still!

It’s possible but I don’t know how.