Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

GUI Text Input?

Asked by 10 years ago

So i am trying to figure out how to detect a certain text input from a user like lets say

plr = game.Players.LocalPlayer
plrgui = plr.PlayerGui
websites = plrgui.NNet.Domains
oops = plrgui.NNet.Notices.Error

if input == "www.whatever.com" then
    websites.whatever.Visible = true
else
    oops.Visible = true
    wait(3)
    oops.Visible = false
end

I have no idea how to receive input from a text box.

So my question is:

How can we have a "local script" that checks input from a textbox and if the text is correct it will then return into showing the proper gui?

2 answers

Log in to vote
1
Answered by 10 years ago

TextBox's have a FocusLost event which fires when someone has typed something into a textbox. So if you want to recieve input, you would do this:

local TextBox = script.Parent.TextBox
TextBox.FocusLost:connect(function()
    input = TextBox.Text
end)

Basically, everytime someone has finished typing something into the textbox, the input will be whatever the Text is. Hope this helped!

Note: For more information on FocusLost, click here: FocusLost

Ad
Log in to vote
0
Answered by 10 years ago
local plr = game.Players.LocalPlayer
local plrgui = plr.PlayerGui
local websites = plrgui.NNet.Domains
local oops = plrgui.NNet.Notices.Error


isValidURL = function(url)
    local valid = false
    local site

    for _,v in pairs(websites:GetChildren()) do
        if string.lower(v.Name):match(string.lower(url)) then
            valid = true
            site = v
        end
    end
    return valid,site
end

script.Parent.TextBox.FocusLost:connect(function()
    local url = script.Parent.TextBox.Text

    local valid,site = isValidURL()
    if valid == false then
        oops.Visible = true
        return
    end

    site.Visible = true
end)

This is un-tested and I'm at school so IDK if it works but that might help a little bit!

Answer this question