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)
Maybe Add A Value To The Zombie And Name It And Check It If That Value Is There?