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

How would I make it so that my NPC can't leave a certain area?

Hey scriptinghelpers, I'm currently working on something different than what I was. I was wondering how would I make it so that my NPC can't leave a certain area? For example if my NPCs name was "Zombie" but I didn't want the "Zombie" following players to the SpawnLocation, how would I make it so that "Zombie" would stay in the area I want it too? I'm actually not sure how to do this, so the only sample code I can provide is my kill on touch script. I have parts around the area that I want the "Zombie", I was thinking that I would use a kill on touch script if something but I'm not sure what that something is. Thanks for the help in advance! I really appreciate it. Sorry to bother with a simple question! I'm only here to learn.

This is a script inside of a part.

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Parent.Name == "Zombie" then--I don't know.
		hit.Parent.Humanoid.Health = 0
	end
end)

1 comment

0

I tested a few things out and I'm having no luck.

1 answer

✓ Accepted answer

Maybe Add A Value To The Zombie And Name It And Check It If That Value Is There?

2 comments

0

That's actually a really good idea, I didn't even think about that. Thank you.

0

Thanks! Did it work?

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