Jump to content

Recommended Posts

If there already is one, don't spawn another one. You can cycle through global variable Prefabs to find out what already exists.

 

inst:AddComponent("childspawner")
inst.components.childspawner.childname = "westy"
inst.components.childspawner:StartSpawning()
inst.components.childspawner.maxchildren = 1
 
    if inst.components.leader then
 
        local x,y,z = inst.Transform:GetWorldPosition()
 
        local ents = TheSim:FindEntities(x,y,z, 100, {"westy"})
 
        for k,v in pairs(ents) do
 
            if v.components.follower then
 
                inst.components.leader:AddFollower(v)
 
            end
        end
        for k,v in pairs(inst.components.leader.followers) do
 
            if k:HasTag("westy") and k.components.follower then
 
                k.components.follower:AddLoyaltyTime(99999)
 
            end
           end
   end
end
 
This is in my character file, it spawns the npc and is only allowed to make one yet two spawn. I have no clue why.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...