Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

1 comment

0

Then I would have to reprogram all of my guns, which I'm not doing that. But thanks for the help.

This discussion is preserved as it was. New answers, comments, and votes are closed.