Jump to content

Returning one at random


Somnei

Recommended Posts

I'm trying to get this function here:

 

     local function OnCreate(inst, player)        return FindEntity(player, 50, function(guy)        if guy:HasTag("spiderchan") then            return not (guy:HasTag("spiderbone_follower"))                    endend)    end    local player = GetPlayer()    spider =     OnCreate(inst, player)        if spider ~= nil then    print(spider)    spider:AddTag("spiderbone_follower")    inst.name = "Spiderbone ("..spider.name..")"    spider.components.follower:SetLeader(inst)    end

 

to return one of the followers and set its leader while adding a tag to prevent it from being set again.

Right now it works perfectly if you only have one follower, but with several it just resets their leaderships or doesn't work at all.

 

What should I do? x:

Thank you for reading!

Link to comment
Share on other sites

@SophieTheDog, not enough information to accurately determine the problem. Please provide the full code.

Though, I think it might have something to do with the inst variable passed into the SetLeader function.

 

It's alright, stayed up all night to fix it.

rip sleep but it works now

 

I think the problem was me trying to set things from within the item prefab, so I basically I just made a function inside the prefab it was trying to change leadership for instead.

 

Pretty sure my mod is almost finished now! n w n

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...