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

Why doesn't the TextBox update when I type into it?

Asked by 6 years ago
Edited 6 years ago

Ok, so here's the scoop. I'm trying to make a brick that the player can 'type into'. Here's my code:

onClicked (Global)

-- A script by fartymarty02. Allows players to type into a text field on a part.
-- Credit is appreciated, but I won't force it. I create these for the community.

timeOut = script.Parent.timeOut.Value -- Time in TICKS, change the value to make it shorter/longer. Change it to -1 to make it never end.

-- Don't go under this unless you know what you're doing

function onClicked(player)
    if script.Parent.InUse.Value then -- stops conflict of scripts.
        print("Already in use!")
        return
    end
    Instance.new("ScreenGui", player.PlayerGui)
    local g = Instance.new("TextBox", player.PlayerGui.ScreenGui)
    g.Position = UDim2.new(.5, 0, .5, 0) -- offscreen
    g.Size = UDim2.new(.1, 0, .1, 0)
    print("Gui added.")
    local focus = script.Focus:clone()
    focus.Parent = player.PlayerGui.ScreenGui
    local counter = 0
    script.Parent.InUse.Value = true
    while counter < timeOut and g.Parent do
        counter = counter + 1
        script.Parent.SurfaceGui.TextBox.Text = g.Text
        print(g.Text)
        wait() -- tick!
    end
    if g.Parent then
        g.Parent:remove() -- adds a 'warning' in orange, dunno how to fix.
    end
    focus:destroy()
    script.Parent.InUse.Value = false
end

script.Parent.ClickDetector.MouseClick:connect(function(p) onClicked(p) end)

Focus (Local)

g = script.Parent.TextBox
g:CaptureFocus()

function onFocusLost()
    g.Parent:remove()
end

g.FocusLost:connect(onFocusLost)

But the thing is, neither the Gui nor the brick update when I type into it! What makes this stranger is that it actually works in Studio Test, but not Public Test. What am I doing wrong? Is there even a way to get Gui-based Input like this? will FilteringEnabled muck this up like everything else? (Yes I am aware the box shows up, I won't make it do that in the future though.)

EDIT: And yes, CaptureFocus works, and the text updates visually, but not in the Text value.

0
its because of FE so use remote events  User#23365 30 — 6y
0
How would I go about using those? @EXpodo1234ALT dominoplayer6 -15 — 6y

Answer this question