Codelyy Posted June 5, 2015 Share Posted June 5, 2015 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) doif k.prefab=="nightmarepet" thenk:Remove() print("nightmarepet removed")endendend 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. Link to comment https://forums.kleientertainment.com/forums/topic/54859-follower-removed-after-save/ Share on other sites More sharing options...
DarkXero Posted June 6, 2015 Share Posted June 6, 2015 Change OnSave to OnDespawn and useinst.OnDespawn = OnDespawn Link to comment https://forums.kleientertainment.com/forums/topic/54859-follower-removed-after-save/#findComment-644250 Share on other sites More sharing options...
Codelyy Posted June 6, 2015 Author Share Posted June 6, 2015 Change OnSave to OnDespawn and useinst.OnDespawn = OnDespawnthat didn't work Link to comment https://forums.kleientertainment.com/forums/topic/54859-follower-removed-after-save/#findComment-644261 Share on other sites More sharing options...
DarkXero Posted June 6, 2015 Share Posted June 6, 2015 (edited) You are usinglocal function OnDespawn(inst) for k,v in pairs(inst.components.leader.followers) do if v.prefab == "nightmarepet" then v:Remove() print("nightmarepet removed") end endendright? Also, it should be a v instead of a k, I think. Edited June 6, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/54859-follower-removed-after-save/#findComment-644263 Share on other sites More sharing options...
Codelyy Posted June 6, 2015 Author Share Posted June 6, 2015 You are usinglocal function OnDespawn(inst) for k,v in pairs(inst.components.leader.followers) do if v.prefab == "nightmarepet" then v:Remove() print("nightmarepet removed") end endendright? 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 Link to comment https://forums.kleientertainment.com/forums/topic/54859-follower-removed-after-save/#findComment-644267 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now