Array adds same item twice (Problem)

I make a simple array with a Textbox input where the player enters a name and presses Enter. The blueprint code literally is instructed to add the name written by player, but it adds it two times for some weird reason. More weird is that when I try to fix this by simply removing “last index” from the array to minus the extra name that was added, it actually erases 2 items, making it zero. Anyone with same problem?

135355-array+2.png

If your game multiplayer? Are you running more than one client at a time when doing this?

My game is local multiplayer based, but the code is not designed in such a way that it would add two instead of one at a time. No I do not run multiple clients, just the Unreal engine test version from “Play” button.

Well, you should know that depending on how you create your widgets(it looks like you’re running this code in a widget actor, right?), you may easily be running code twice or more depending on number of clients you have running.

When you run this code is dedicated server option checked? Can you try running this code with an extra client, to see what happens?

I know there is only one client running I only have one test window open when I play the game through unreal engine. I do not know about dedicated server option, where can I check it? I tried to google it, could not find anything that would be of help.

135425-_21.png

Is that checked?

I checked it and tried, but did not fix anything. What is that thing for anyway?

It simulates your client running on a dedicated server.

I don’t know what your issue is I guess. I had the exact same problems until I learned how actor instances work in a multiplayer setting, but if you’re not running more than 1 client I don’t know what it could be

The event is called when a text is committed. But committed means pressing enter or changing focus. So your player presses enter, the focus changes to a different widget, and the event is called two times. Simply make a switch on the commit method and execute “OnEnter” only.