UserInputService Issue

So I have a predictive text system. It all works fine except I want to make it so that when you press tab, it automatically fills. I’ve made it fill but when I press tab, the text box gets a space inserted with it. Does anyone know how to prevent this?

That is a normal behavior of typing a tab key (try it on notepad for instance), to fix this just use a different key other than tab.

I know there’s a way to stop it from happening, for example I’ve heard RunService.RenderStepped:Wait() but it’s not working in this situation.