• Frame opens twice and invalid object error
    4 replies, posted
I'm making a custom Chat Box, and i've already disabled the default chat. However, whenever I press my chat bind, my custom chat box frame opens two separate times, so I have to close both to exit the chat box. I noticed that whenever I press my chat bind, "global chat" is printed twice in the console. Why is the hook reading the bind twice? https://files.facepunch.com/forum/upload/483843/35bda8a9-55e9-40c4-9e74-85c5c6cda900/image.png Another issue is that since I'm replacing the default chat, I read that i need to replace the oldAddText function as well. However, on line 103 and 104, I get an error "Tried to use invalid object (type Panel) (Object was NULL or not of the right type)". Shouldn't the those lines only be run if the object is a player? https://files.facepunch.com/forum/upload/483843/867c9dcd-0c23-473f-a5fd-5dd30d6af17c/image.png I've spent the past 2 days trying to figure it out and researching as much as I can, but haven't found much results.
As the error suggests, the problem is not the player object, but the PANEL, i.e. bchat.rtbox is a removed panel. Look at the pressed variable.
Hmm, I can't seem to figure out what's wrong with the panel. I initialized a table at the start of the code with bchat={} . https://files.facepunch.com/forum/upload/483843/b323e0e9-1853-4a1e-bb90-29847415de06/image.png Also, what do you mean by look at the pressed variable?
https://files.facepunch.com/forum/upload/1804/a0ebecfc-748d-4b7b-8a80-656fdf82a8fa/image.png Its up to basic debugging at this point, add prints to all places where bchat is set, and in all places where bchat.rtbox is created/removed, etc, etc. Also worth noting that auto refresh can cause problems with code too if you are not aware of what you are doing. For example if you just have "bchat={}" and you do auto refresh, your bchat variable will be reset, so you should check if it already exists before "creating it".
Thank you, i will look into it
Sorry, you need to Log In to post a reply to this thread.