I want to spawn an NPC using my code only. What are the requirements to do this? What attributes must I set?
So far, I have tried something like this:
local humanoid = Instance.new("Humanoid")
humanoid.RigType = "R15"
but seems that nothing spawns.
I want to spawn an NPC using my code only. What are the requirements to do this? What attributes must I set?
So far, I have tried something like this:
local humanoid = Instance.new("Humanoid")
humanoid.RigType = "R15"
but seems that nothing spawns.
The problem with your script is that you are only creating a new Humanoid object, not an actual model of an NPC. The script below uses an NPC model that is already made, then clones it into the workspace.
I'll assume that the properties that you want in the NPC are already set in the actual model.
local replicatedStorage = game:GetService('ReplicatedStorage')
local npc = replicatedStorage:WaitForChild('NPC')
local function cloneNPC()
npc:Clone().Parent = workspace
end
cloneNPC() -- call this function whenever you want a new clone
I don't want one that is already made but to create this - how do I achieve this?
That would mean creating and setting all the properties necessary in an NPC. joints, decals, humanoid, torso, limbs, everything. Why would you want to do all this within the program?
It's a lot of work, and if you wanted animations then that is a whole other aspect as well.
OK thanks for your reply - perfectly answers what I want!
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
That just creates a new humanoid object, not an actual model of an NPC.
You'll have to create each indicula part of the NPC, and position them correctly in the NPC. Then you'll have to insert each script that you wanted into the NPC (Animation, etc.) I think your best option is to put an already made NPC into server storage and just clone it from there and put it into workspace.