Archny Posted November 3, 2019 Author Share Posted November 3, 2019 (edited) This is because the book is in the player inventory/container, therefore it has no valid ID and the script won't work. Ghaunadaur Big thanks man, you helped me find the solution. Although I didn't go for quest since I don't have a good understand of how it works yet, but I went into a slightly different approach. I took the book in question and I added it in a custom cell and then I referenced it into the script, and then I used this ObjectReference to register all keys that I need, then I used this same Object to unregister all keys when the player hits "scape" or "tab" in order to close the book. So here is the final solution. Scriptname myBookScript extends ObjectReference ObjectReference Property myBookRef auto int mNumpad1 = 79int mNumpad2 = 80int mNumpad3 = 81 int mScape = 1int mTab = 15 Event OnRead() myBookRef.RegisterForKey(mNumpad1) myBookRef.RegisterForKey(mNumpad2) myBookRef.RegisterForKey(mNumpad3) myBookRef.RegisterForKey(mScape) myBookRef.RegisterForKey(mTab) EndEvent Event OnKeyDown(Int KeyCode) Debug.notification("A registered key has been pressed") If KeyCode == mNumpad1 Debug.notification("1st option") elseIf KeyCode == mNumpad2 Debug.notification("2nd option") elseIf KeyCode == mNumpad3 Debug.notification("3rd option") EndIf ;==responsable to unregister all registered keys if keyCode == mScape || keyCode == mTab myBookRef.UnregisterForAllKeys() Debug.notification("Book closed, all key unregistered") EndIfEndEvent Thanks to everyone who gave their time to help. Also if you guys find any performance issue with this code please share here. Edited November 3, 2019 by Archny Link to comment Share on other sites More sharing options...
Recommended Posts