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

How to make a NPC dont follow a player with a helmet? [closed]

Asked by 7 years ago

I'm looking for a way to make an NPC with the pathfinding system not follow a player with a specific helmet from a morph, but I have no idea how to do this,can someone help me? the model: https://www.roblox.com/catalog/128800750/Advanced-SCP-096 ?

Closed as Not Constructive by hiimgoodpack, Void_Frost, lukeb50, and PyccknnXakep

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
-1
Answered by 7 years ago

Open up the "Main" Script that you find inside the model. I'd love to explain how this actually works, but this code is really ugly (no indentation!) so I'll just give you the short version.

I think the line you're looking for is line 128:

if TargetModel.className=="Model"and TargetModel~=SCP096 and TargetModel.Name~=SCP096.Name and TargetModel:FindFirstChild("Torso")and TargetModel:FindFirstChild("Head") then

I believe this is what checks to see if the target is player (there are better ways to do this; see addendum). Add one clause to check that the hat isn't a member of the character:

and not TargetModel:FindFirstChild("HAT_NAME_GOES_HERE")

So that line 128 becomes

if TargetModel.className=="Model"and TargetModel~=SCP096 and TargetModel.Name~=SCP096.Name and TargetModel:FindFirstChild("Torso")and TargetModel:FindFirstChild("Head") and not TargetModel:FindFirstChild("HAT_NAME_GOES_HERE") then

addendum: It makes more sense to just check that the target is a player with Players:GetPlayerFromCharacter() rather than checking for a Torso and Head independently and then checking that it's not the NPC itself. A better replacement for Line 128 would be:

if game.Players:GetPlayerFromCharacter(TargetModel) and not TargetModel:FindFirstChild("HAT_NAME_GOES_HERE") then

0
Good, Good. Smaltin 46 — 7y
0
Please do not encourage people to post these questions. You should not be helping with a model made by someone else and instead tell them to contact the maker. lukeb50 631 — 7y
Ad