Textbox not working

  1. What do you want to achieve? Keep it simple and clear!

I want to make a texbox prompt thing where if you put a text to a textbox it will change a textlabel text

  1. What is the issue? Include screenshots / videos if possible!

when i apply the text it didnt change anything or print anything.

Video:

Code:

local textbox = script.Parent.TextBox
local initiateCode = script.Parent.InitiateCode

if textbox.Text == “Remove” then
initiateCode.Text == “[0],[0],[0]”
print(“Removed”)
end
1 Like

So far I can see, you have the correct paths to the text, and the code thinks the same.

However, your code keeps going, reaches the if statement and checks if it’s true. At that point (milliseconds into the game) the textbox is probably " ", so the if statement is ignored and the code keeps going.

You have to trigger an event to run the if statement. You could probably use the UserInputService to check if the player presses the Enter button. Once pressed (the event) will connect to a function that will run this code:

Then it should execute properly.

1 Like

Is this connected to a event? If not thats what ur issue is.

You can either connect the function to an event or use a loop to continuously check if textbox.Text is equal “Remove”

1 Like

Ur script checks one time when game run, this script run when Text changes

local initiateCode = script.Parent.InitiateCode
local textbox = script.Parent.Parent.TextBox

textbox:GetPropertyChangedSignal("Text"):Connect(function()
   if textbox.Text == "Remove" then
        initiateCode.Text = "[0],[0],[0]"
       print("Removed")
   end
end)
2 Likes

this also worked, tysm. character limits bruh

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