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

Help me with my NPC?

Asked by 9 years ago

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?

0
On line 04 Put `Darkgreen.TeamColor` woodengop 1134 — 9y
0
On line 3, Make it 'game.Teams.Undead' Shawnyg 4330 — 9y

Answer this question