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)
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
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.
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.
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.
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)
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.