Hello! So I wanted to make a system that finds text that a player inputted into the TextBox and if it’s the same as a code, and the player clicks a TextButton, then it will open a Gui and hide the TextBox one. However, it doesn’t work.
Script:
script.Parent.MouseButton1Click:Connect(function(Clicked)
script.Parent.Parent.TextBox:GetPropertyChangedSignal(“Text”):Connect(function()
local MessageInTextBox = script.Parent.Parent.TextBox.TextEditable.Text
if MessageInTextBox == “Commander_2736” and Clicked then
game.StarterGui.CommanderSystem.VerificationPanel.Enabled = false
game.StarterGui.CommanderSystem.CommandPanel.Enabled = true
end
end)
end)
GetPropertyChangedSignal() will execute when the textbox’s text is changed, so you should remove it, and Guis are not stored on StarterGui, each player recieves a folder called PlayerGui which stores everything that was put on StarterGui before running the game, so assuming your script is a LocalScript you should do:
local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
script.Parent.MouseButton1Click:Connect(function()
local MessageInTextBox = script.Parent.Parent.TextBox.TextEditable.Text
if MessageInTextBox == "Commander_2736" then
Client.PlayerGui.CommanderSystem.VerificationPanel.Enabled = false
Client.PlayerGui.CommanderSystem.CommandPanel.Enabled = true
end
end)
Well I’m seeing a few red flags here. One thing being, you’re creating a new event listener every time you click on the button. Basically what this means is that each time the player clicks the button, an additional function will run when ever the textbox’s text changes. This is definitely not desirable, as at that point you’ll have dozens of the same thing running.
With that said, your biggest issue is the fact you’re modifying the StarterGui rather than the GUI this script is in. GUIs in StarterGui will only be seen when your character respawns.
Let me try to clean up your script a bit:
--//Config
local CODE = "Commander_2736"
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local textBox = script.Parent.Parent:WaitForChild("Textbox")
--//Frames to make visible?
local verificationPanel; --//Path to the verification panel. Not sure where this is located
local commandPanel; --//Path to the command panel. Again, not sure where this is located in the same GUI as this script
local function testCode()
if textBox.Text == CODE then
verificationPanel.Enabled = false
commandPanel.Enabled = true
end
end
script.Parent.MouseButton1Down:Connect(testCode)
This should be close. Again, not really sure where your UI panels are located, or if it’s even the same GUI as this script is in. I’ve made some assumptions as to what you’re trying to do, so hopefully this is close.