SurfaceGUI TextBox issues

Hello!

I have been trying to make a certain “security” code system with a textbox. Basically, if you enter the correct text value to the textbox (TextBox.Text), it will do certain things. However, it won’t work. I have tried few changes to the script, but it just won’t work. It also doesn’t print any errors.

Script:

local textbox = script.Parent
local securitystatus = textbox.Parent.Status
local proximityprompt = textbox.Parent.Parent.Parent.Parent.Parent.Parent.HackingTables.HackingTableInside.Core.ProximityPrompt

textbox.Parent.Changed:Connect(function()
   if textbox.Text == "32$EKIRTS!312" then
   	securitystatus.Text = "Success"
   	securitystatus.TextColor3 = Color3.fromRGB(0, 255, 85)
   	textbox.Visible = false
   	proximityprompt.Enabled = true
   end	
end)
2 Likes

It’s doing if textbox’s parent’s properties are changed, but not the textbox itself. Change textbox.Parent to just textbox.

2 Likes

It didn’t work with textbox.Changed either, unfortunately.

Try changing ‘.Changed’ to ‘:GetPropertyChangedSignal(“Text”)’ as shown below as it may help solve the issue:

local textbox = script.Parent
local securitystatus = textbox.Parent.Status
local proximityprompt = textbox.Parent.Parent.Parent.Parent.Parent.Parent.HackingTables.HackingTableInside.Core.ProximityPrompt

textbox:GetPropertyChangedSignal("Text"):Connect(function()
	if textbox.Text == "32$EKIRTS!312" then
		securitystatus.Text = "Success"
		securitystatus.TextColor3 = Color3.fromRGB(0, 255, 85)
		textbox.Visible = false
		proximityprompt.Enabled = true
	end	
end)

1 Like

Try putting a print under this line and see if you get anything back in the output.

1 Like

Hmm, that’s weird. It doesn’t print anything, even when I keep changing the text.

That means .Changed doesn’t work. Consider the solution @1Keeth provided.

Yeah, I used :GetPropertyChangedSignal instead of .Changed, however, it still won’t print anything. I really do not know what could be causing this.

If you have it parented to a surface or billboard Gui within a part in the workspace, then try setting the Adornee property to the part and parenting it to the StarterGui service. This should let you type in the text box and it may resolve the issue.

You will also have to update the proximityprompt property.

I recreated a similar system in an empty place in roblox studio and it seemed to solve the issue. Hope this helps :slight_smile:

2 Likes

Thank you for your tip, but it seems that it still didn’t help.

1 Like

Need more information to help you see the problem. Like your file structure. That text box seems a bit buried. You sure you got the locations right in the script … again use a print to see. Print
textbox.Parent.Parent.Parent.Parent.Parent.Parent.HackingTables.HackingTableInside.Core.ProximityPrompt … is it coming back right … That many Parents is always a red flag. Sure there isn’t a better shorter way to get that location.

Is this script located on the client or on the server? Is it intentional that the TextBox is disappearing right before the ProximityPrompt is enabled?

Thanks for your support, though this is not what I intend to do. The ProximityPrompt doesn’t affect the TextBox in any way. The TextBox enables the ProximityPrompt, if there is a correct password in the TextBox. Also don’t worry, I don’t care about hackers or possible password leak. The game is not public and it’s just for a roleplay simulation of a certain event, won’t be used for any entertainment game purposes.

I’ll try to rework this script to my needs. I’ll let you know if it works or not, though thanks again.

2 Likes

I just tried reworking it, perfectly to my needs, but it still doesn’t work. I implemented warn prints, to realize what is causing this issue. However, I’m not sure what exactly it is.

The script:

local PASSWORD = "32$EKIRTS!312"
local HackingTables = workspace:WaitForChild("HackingTables")
local InsideMonitor = HackingTables:WaitForChild("HackingTableInside")
local Core = InsideMonitor:WaitForChild("Core")
local ProximityPrompt = Core:WaitForChild("ProximityPrompt")

warn("BEFORE TEXTBOX")
local TextBox = script.Parent
local Screen = TextBox.Parent.Parent.Adornee

warn("BEFORE FOCUS LOST")
TextBox.FocusLost:Connect(function(enterPressed)
	warn("FOCUS LOST")
	if enterPressed then
		local Text = TextBox.Text
		if Text == PASSWORD then
			print("CORRECT PASSWORD")
			ProximityPrompt.Enabled = true
		else
			print("WRONG PASSWORD")
		end
	end
end)

Only warnings that get printed are “BEFORE TEXTBOX” and “BEFORE FOCUS LOST”, meaning that the .FocusLost function doesn’t work properly, or not at all.

This is a local script, right? FocusLost only works on the client.

No, it’s a ServerScript.

characters

That’s exactly why it’s not working, focus is only tracked on the client. Try changing it to work in a local script and see if it outputs anything.

1 Like

Hmm, I don’t know what’s wrong this time. I made the script a LocalScript and reworked it a little bit.

local PASSWORD = "32$EKIRTS!312"
local SurfaceGUI = script.Parent.Parent.Parent
local HackingTables = SurfaceGUI.Parent.Parent.Parent.Parent
local InsideMonitor = HackingTables:WaitForChild("HackingTableInside")
local Core = InsideMonitor:WaitForChild("Core")
local ProximityPrompt = Core:WaitForChild("ProximityPrompt")

warn("BEFORE TEXTBOX")
local TextBox = script.Parent

warn("BEFORE FOCUS LOST")
TextBox.FocusLost:Connect(function(enterPressed)
	warn("FOCUS LOST")
	if enterPressed then
		local Text = TextBox.Text
		if Text == PASSWORD then
			print("CORRECT PASSWORD")
			ProximityPrompt.Enabled = true
		else
			print("WRONG PASSWORD")
		end
	end
end)

obrazek
“HackingTables” model is located in Workspace.

The warnings don’t even get printed this time.

LocalScripts don’t work in workspace, only in descendants of the player (i.e. PlayerGui)

If I’m right, it didn’t work with the SurfaceGui being in StarterGui service and having the screen as adornee either. That’s why I tried putting it directly into the model.

Though, I’ll try it once more with the adornee method, and let you know if it works or not.