Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a script that prevents NPC from harming players on a specific team?

Asked by 9 years ago

Im just starting to design a game, so this is my first time scripting. I tried to use the anti team killing script along with the sword script, heres what i tried:

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 = humanoid
    creator_tag.Name = "creator"
    creator_tag.Parent = Player
end
function untagHumanoid(humanoid)
    if Player ~= nil then
        local tag = Player:findFirstChild("creator")
        if tag ~= nil then
            tag.Parent = nil
        end
    end
end
0
Please put the code in a code block YellowoTide 1992 — 9y

Answer this question