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

Text box only gives message when it has no Text?

Asked by 5 years ago
Edited 5 years ago

So I'm making this game and the user has to enter a custom name, but whenever I test it and put a name, it always comes up with the response used when there is nothing there.


--things-- local WR = script.Parent.Parent:WaitForChild("Warning") local NM = script.Parent.Parent local NN = game.ReplicatedStorage:WaitForChild("NewName") --texts-- local preview = "My name is"..NN.Value local warning2 = "This field cannot be blank." --variables-- --script-- script.Parent.MouseButton1Click:Connect(function() if NM.Text ~= "" then script.Parent.Visible = false repeat wait() NN.Value = NM.Text until NN.Value == NM.Text for a = 1,#preview do WR.Text = string.sub(preview,1,a) wait() end wait(3) WR.Text = "" else script.Parent.Visible = false for a = 1,#warning2 do WR.Text = string.sub(warning2,1,a) wait() end wait(3.2) script.Parent.Visible = true end end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
    --things--
    local WR = script.Parent.Parent:WaitForChild("Warning")
    local NM = script.Parent.Parent
    local NN = game.ReplicatedStorage:WaitForChild("NewName")

    local warning2 = "This field cannot be blank."
    --variables--
    local preview
    --script--
    script.Parent.MouseButton1Click:Connect(function()
        if NM.Text ~= "" then
            script.Parent.Visible = false
            repeat wait()
                NN.Value = NM.Text
            until NN.Value == NM.Text
            preview = "My name is "..NN.Value   
            for a = 1,#preview do
                WR.Text = string.sub(preview,1,a)
                wait()
            end
            wait(3)
            WR.Text = ""
        else
            script.Parent.Visible = false
            for a = 1,#warning2 do
                WR.Text = string.sub(warning2,1,a)
                wait()
            end
            wait(3.2)
            script.Parent.Visible = true
        end
    end)

you seted nm after setting the preview value, that is, the preview is not changed.

Hope this helps

0
It works, thank you for the help. gamemaster60788 61 — 5y
Ad

Answer this question