local VNPC_Gen = require(script.Parent.VNPC_Gen) --Require the module
local MyRandomNPC = VNPC_Gen.NewNPC() --Generate a new NPC
MyRandomNPC.Parent = workspace
Generating an NPC with custom parameters (all of them are optional and can be set to nil):
local VNPC_Gen = require(script.Parent.VNPC_Gen)
local MyRandomNPC = VNPC_Gen.NewNPC("Male", 300000, true, false) --Forced gender, custom seed, random faces enabled, exclude repeating seed with other generated NPCs (Won't work if a custom seed was entered)
MyRandomNPC.Parent = workspace
This will create a male NPC using the seed 300000 and a randomized face.
Performance
How it performs
I spawned 55 NPCs with a 0.01 wait interval and noticed no lag spikes. However, creating over 60 NPCs may cause visual lag due to Roblox’s handling of Humanoids.
this is not really that serious but I noticed your typechecking in .NewNPC can be mistaken by the intellisense as a string, and also scripts with --!strict flag on, will error because they need to input the exact string for each parameters
this can be fixed however, by using the string, number, boolean types. and to make them optional, suffix them with ?
this is necessary for --!strict (even though I rarely use it, but theres a lot of people out there) users to use your module
one more thing, the gender string? type can be replaced with a union type so people don’t accidentally misspell (and also the intellisense will suggest the valid genders):
Hi, relating to your comments of the top, ’ However, creating over 60 NPCs may cause visual lag due to Roblox’s handling of Humanoids.’ … can you give the low down on what this means?
Thanks
My module simply gives npcs clothing and accessories, no scripts are automatically given to npcs.
So, you can probably generate as much as you want without major concerns.
Thank you!
I’m working on hopefully revamping this because this hasn’t been updated in a while
and this module doesn’t really allow for more stuff to be added.
I’m planning on turning this into a full-fleshed plugin with a comprehensive UI, where
you can add your own “races”, style discriminators (certain clothing can only be worn with
other similar clothing), support for R6, R15 and custom rigs.
This plugin will be paid (haven’t decided on a fair price yet), but don’t worry!
As the plugin is updated I will also keep updating the module itself so you can do basically
all the plugin can do but without the UI and tools the plugin will give.