Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Text box only gives message when it has no Text?

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

✓ Accepted answer
	--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

1 comment

0

It works, thank you for the help.

This discussion is preserved as it was. New answers, comments, and votes are closed.