I need a script that allows NPC to attack players on one team, but deal no damage to players on another team. Heres what I tried: (combination of sword script and teamkilling script
local Player = game.Players:GetPlayerFromCharacter(hit.Parent) humanoid = workspace.DroolingZombie Darkgreen = game.teams.Undead if Player.TeamColor ~= Darkgreen then tagHumanoid(humanoid) humanoid:TakeDamage(0) wait(1) untagHumanoid(humanoid) end function tagHumanoid(humanoid, player) local creator_tag = Instance.new("ObjectValue") creator_tag.Value = player creator_tag.Name = "creator" creator_tag.Parent = humanoid end function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end
I'm new to coding, so this is my first try. Help?