Ok I this time I will save you what I am doing and get straight to what I want to make things easier
I want npcs to be able to move around in a certain radius and they be able to respawn when they die. How do I do those things? If you want the solution highlight then both answers must be in the same comment
These are things you should search around for and attempt yourself first before asking them on the forums. I’m sure there are also many resources on the toolbox you can use as personal reference. Remember that this category is not for receiving free code.
Do you know what your requirements are, let alone what functions you’re going to be working with? It is important that you think for yourself to lay a foundation for your efforts and then work from there.
The first thing, which is easy to handle, is respawning your NPC. Obviously, the first thing you’d need is to know how to check for when the NPC dies. From there, you’ll want to look into how to make the NPC spawn back up again. There are definitely resources you can reference for NPC respawning in the toolbox, I suggest you have a look at those.
The second is making an NPC move within a certain radius. Your point here is unclear, as this can mean more than one thing: having the NPC wander within a certain area or restricting an NPC’s movements to a certain area, whether that’s literal restriction or the NPC going back to its original position if its movement is outside that area. Whichever the case is, first you need to know how to move a Humanoid in the first place and how to determine a radius from its original position. This’ll serve as your basis for delving into the NPC completing actions when certain conditions are met.
The rest is up to you. Try it out first. If you can’t, then you need to build up your basic knowledge of programming first before trying tasks that are above your level. If you don’t fundamentally understand what’s going on behind your code, then writing the code, let alone maintenance, will be difficult for you.
The thing of move a NPC in a certain radius is unclear, i don’t know what do you mean with that.
The other thing of respawn characters is easy, i guess, i was about to file a request of :Respawn(x,y,z)
By the way, first, i would make two NPCs, one in the Workspace Service, and the other in ServerStorage, and now, you must add this script inside both NPCs:
local RespawnTime = 5
local YourNPCNameHere = "NPC"
local Character = script.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
local SerStorage = game:GetService("ServerStorage")
Humanoid.HealthChanged:Connect(function()
if Humanoid.Health == 0 then
wait(RespawnTime)
local SSNPC = ServerStorage:FindFirstChild(YourNPCNameHere)
NPCClone = SSNPC:Clone()
NPCClone.Parent = game:GetService("Workspace")
Character:Destroy()
end
end)
I just wrote a basic code, it’s not optimized and that stuff, i just wrote it to help you a bit. Everything else to optimize your code or making it better should be researched by yourself, but i hope this helps.