Basically, I have a function that stops people from being able to team-kill. What I want to do, is add a certain team to a white list. Meaning, say you have a team named "Team1" on the Whitelist, anyone on Team1 will then be able to team-kill each other.
Code:
function Fire(ShootingHandle)
local PierceAvailable = Module.Piercing
PiercedHumanoid = {}
if FireAnim then FireAnim:Play(nil,nil,Module.FireAnimationSpeed) end
if not ShootingHandle.FireSound.Playing or not ShootingHandle.FireSound.Looped then ShootingHandle.FireSound:Play() end
local Start = (Humanoid.Torso.CFrame * CFrame.new(0,1.5,0)).p--(Handle.CFrame * CFrame.new(Module.MuzzleOffset.X,Module.MuzzleOffset.Y,Module.MuzzleOffset.Z)).p
local Spread = Module.Spread*(AimDown and 1-Module.SpreadRedution or 1)
local Direction = (CFrame.new(Start,Mouse.Hit.p) * CFrame.Angles(math.rad(-Spread+(math.random()*(Spread*2))),math.rad(-Spread+(math.random()*(Spread*2))),0)).lookVector
while PierceAvailable >= 0 do
local Hit,EndPos = RayCast(Start,Direction,5000,Character)
if not Module.ExplosiveEnabled then
if Hit and Hit.Parent then
local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
local TargetTorso = Hit.Parent:FindFirstChild("Torso")
local TargetTEAM = Hit.Parent:FindFirstChild("TEAM")
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
if TargetTEAM and TargetTEAM.Value ~= TEAM.Value then
InflictTarget:FireServer(TargetHumanoid,
TargetTorso,
(Hit.Name == "Head" and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage,
Direction,
Module.Knockback,
Module.Lifesteal,
Module.FlamingBullet)
PiercedHumanoid[TargetHumanoid] = true
end
else
PierceAvailable = 0
end
end

8 comments
Do use more local variables.
If you're not going to help with my problem do not comment, thanks.
I'm recommending you to use local variables, as global variables are bad practice. They make your code messy (as shown), pollute the global namespace and they can increase risks for name collisions. You should use local variables to prevent any possible future conflict
Wow, snapping at someone who gave a good suggestion.... and this is where I don't look at this question anymore
He's pointing out something obvious, like I don't know. Basically just being a smart- by adding "thanks". His comment wasn't needed, and neither was yours.
You could probably do something like create a table of whitelisted teams, like add an else statement to if TargetTEAM and TargetTEAM.Value ~= TEAM.Value where you check to see if their team is whitelisted
" If you're not going to help with my problem do not comment, thanks." but he did help lol
"with my problem" > You must have missed that.:) Again, another pointless comment. Thanks for the suggestion, Vulkarin. I'll take it into consideration.