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

How to make this ONLY attack NPC's? [UNANSWERED]

Asked by 10 years ago

It's part of the shadescript, by Stickmasterluke.

function attack(time,attackpos)
    if time-lastattack>=1 then
        local hit,pos=raycast(Torso.Position,(attackpos-Torso.Position).unit,attackrange)
        if hit and hit.Parent~=nil and hit.Parent.Name~=sp.Name then
            local h=hit.Parent:FindFirstChild("Humanoid")
            if h then
                local creator=sp:FindFirstChild("creator")
                if creator then
                    if creator.Value~=nil then
                        if creator.Value~=game.Players:GetPlayerFromCharacter(h.Parent) then
                            for i,oldtag in ipairs(h:GetChildren()) do
                                if oldtag.Name=="creator" then
                                    oldtag:remove()
                                end
                            end
                            creator:clone().Parent=h
                        else
                            return
                        end
                    end
                end

1 answer

Log in to vote
0
Answered by
iLegitus 130
10 years ago

Basically, Make the NPC's Humanoids called "NPCHumanoid", And simply Replace your scripts based off "Humanoid", And make it based off NPCHumanoid. That way it will only find NPC Humanoids to attack,Not Player Humanoids. Hope it helped.

0
Then I would have to reprogram all of my guns, which I'm not doing that. But thanks for the help. TheRings0fSaturn 28 — 10y
Ad

Answer this question