Hiru315 Posted September 10, 2022 Share Posted September 10, 2022 (edited) Quote local function OnKill(victim,inst) if victim and victim.prefab then if victim.prefab == "catcoon" then inst.components.sanity:DoDelta(-300) end end end inst:ListenForEvent( "killed", function(inst,data) OnKill(data.victim,inst) end ) I copied the code from Tutorial basic perks to make my character goes insane when they kill catcoons but got error: Variable 'inst' is not declared. Also is "player.components.talker:Say("...")" is a correct code for DST? Since it doesn't appear in game. Edited September 10, 2022 by Hiru315 Link to comment https://forums.kleientertainment.com/forums/topic/143090-need-help-with-inst/ Share on other sites More sharing options...
Bumber64 Posted September 10, 2022 Share Posted September 10, 2022 Where is inst:ListenForEvent located with respect to your character code? You need to make sure inst actually refers to your character entity. The talker code is fine as long as player is defined. You can use ThePlayer if you're doing console commands. Link to comment https://forums.kleientertainment.com/forums/topic/143090-need-help-with-inst/#findComment-1597579 Share on other sites More sharing options...
Hiru315 Posted September 12, 2022 Author Share Posted September 12, 2022 (edited) It's in my character's prefab lua file here. Where do I put the inst: ListenForEvent instead? wheein.lua Edited September 12, 2022 by Hiru315 Link to comment https://forums.kleientertainment.com/forums/topic/143090-need-help-with-inst/#findComment-1597823 Share on other sites More sharing options...
Bumber64 Posted September 13, 2022 Share Posted September 13, 2022 (edited) It (and the "onhitother" listener) go in your master_postinit function. Also, you can shorten your code to just if victim and victim.prefab == "catcoon" then, since comparing nil to "catcoon" is okay. Edited September 13, 2022 by Bumber64 Link to comment https://forums.kleientertainment.com/forums/topic/143090-need-help-with-inst/#findComment-1597941 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