Jump to content

Recommended Posts

I have made a post about this earlier but i now know the cause behind it unlike when i made that other post.

 

I'm making a character who has a perk where he will summon a shadowcreature to follow him and attack stuff with him. It's currently will be deleted whenever the game saves as i've found out when i only want it to be deleted if i leave the server.

 

I notice this after it became day 2 and it would save and then remove the shadowcreature as the code tells it to do however like i said i only want this code to work if i leave the server.

 

Here the OnSave function: 

local function OnSave(inst, data)
for k,v in pairs(inst.components.leader.followers) do
if k.prefab=="nightmarepet" then
k:Remove() print("nightmarepet removed")
end
end
end

 

I was wondering if anyone know what i can add on so it will only use this function when i leave the server to delete it Only when i leave.

You are using

local function OnDespawn(inst)	for k,v in pairs(inst.components.leader.followers) do		if v.prefab == "nightmarepet" then			v:Remove() print("nightmarepet removed")		end	endend

right?

 

Also, it should be a v instead of a k, I think.

Edited by DarkXero

You are using

local function OnDespawn(inst)	for k,v in pairs(inst.components.leader.followers) do		if v.prefab == "nightmarepet" then			v:Remove() print("nightmarepet removed")		end	endend

right?

 

Also, it should be a v instead of a k, I think.

I made a mistake in spelling XD but i fixed it and now it works :3. Thanks

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...