local TextBox = game.StarterGui.ScreenGui.TextBox local Codes = { [Master] = "star" [Star] = "master" } for i,v in pairs(Codes) do if TextBox.Text == v then TextBox.Text = v end end
I created a text box and if i write Master or Star in it then it should change to the strings so if i put Master then the text of the Textbox should be "star" and if i put Star then it should put "master" in the textbox text
You have to put the code into the players GUI, becuase the GUI goes to the player after the game initialization.
Put the script parented to the text box, and this should work:
local TextBox = script.Parent -- Parent of the script. local Codes = { [Master] = "star" [Star] = "master" } for i,v in pairs(Codes) do if TextBox.Text == v then TextBox.Text = v end end
Later edit*
Sorry for not telling you, you have an error with the table.
You have a library, which means it's a table of variables: then you have to siignalize the variables you want to store, like [Master] and [Star] with square brackets and "", like a string.
Observe:
local TextBox = script.Parent -- Parent of the script. local Codes = { ["Master"] = "star" ["Star"] = "master" } for i,v in pairs(Codes) do if TextBox.Text == v then TextBox.Text = v end end
This should work as intended ;)