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 a NPC dont follow a player with a helmet?

1 answer

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

2 comments

0

Good, Good.

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.

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