Textbox.Text not changing, despite it being in a local script

Hi everyone,

I am programming a very simple store system in my game utilizing a textbox for user inputs. I have seen issues very similar to my one where the Textbox.Text wasn’t updating, however, they were all using server-sided scripts, whilst my script is a local script. Here is my code:

local InputField = script.Parent.Frame.TextBox
local Screen = script.Parent.Frame.Screen

if InputField.Text == "store" then
	Screen.Text = "/ LIST OF PRODUCTS: \nFLASHLIGHT\nWALKIE-TALKIE"
end

The current hierarchy for my GUI is quite simple, it is: StarterGui/TerminalGUI/Frame/Screen.

It is important to keep note that my script is located inside of the TerminalGUI area.

2 Likes

Try changing the value of Screen.Text but using LocalPlayer.PlayerGui

well if this is the whole script then you should be doing InputField:GetPropertyChangedSignal() or InputField.Changed()

InputField:GetPropertyChangedSignal():Connect(function()
  if InputField.Text:lower() == "store" then
    Screen.Text = "/ LIST OF PRODUCTS: \nFLASHLIGHT\nWALKIE-TALKIE"
  end
end)
1 Like

I assume you don’t just call this once like you did here?

your changing the gui in the part. You need to access PlayerGui

local Players = game:GetService("Players")
local player - Players.LocalPlayer
local ur_gui = player.PlayerGui.UR GUI_NAME_HERE

ur_gui.TextLabel.Text = "THIS WORKS NOW YAY!"

you can change GuiObjects without getting PlayerGui

local TextButton = script.Parent -- LocalScript in a TextButton or TextLabel
TextButton.Text = "Text Changed"
1 Like

Why are you using the added function :lower() to the script? What does this do?

Changing the value works, it’s the input field (text box) that is not working. When the user inputs the text, it is not updating even after I press enter.

local InputText = InputField.Text -- Let's say InputText is "STORE"
print(InputText:lower())
--> This would print "store"
print(string.upper("home"))
--> HOME

i’d use string.lower() or string.upper() so your input isn’t case sensitive

Ah, thank you.

Also, what GUI element is actually used to gain users input? I am currently using Textbox (The one with the green logo and the cursor inside.) is there another alternative?

you should keep using TextBoxes for input

you could use TextLabels or TextButtons and check if the player clicks on it, but that would just be extra work especially since a TextBox would do the same thing

So I assume that it must be an issue with the script or is it Roblox?

The text value, is not changing when the user inputs something on their end. However, when I manually change it, it appears to be working just fine.

I’ll add the function you mentioned earlier and see if that helps.

that’s because your orignal script (if that was the whole script) it only checks the text one time
which is when the script is ran

read my first post again

.Changed and :GetPropertyChangedSignal() are events that listen to property changes

I also asked him the same question.

1 Like

Oh my gosh.

Just realized this, and thank you.

Sorry for not reading it thoroughly, I’m away from my computer right now. I’ll add your solution in the morning. For now, I’ll mark your post as the solution.

Completely forgot about scripts only running once lol.

1 Like

My bad for not responding to your original question. Thank you for your insight as well.

I apologize for not paying attention to your questions - a very simple thing to oversee on my end

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.