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

How to detect the text for an editable TextBox?

I'm trying to make a Hand-To gui for a cafe but I don't know how to find an editable TextBox's text. I've tried this script:

local box = script.Parent.Parent.User.Text --user is the textbox
script.Parent.MouseButton1Click:Connect(function(player)
	local NewP = box.Text
	local tool = player.Character:FindFirstChildWhichIsA("Tool")
	local target = game.Workspace:FindFirstChild(NewP)
	tool:Clone().Parent = target
	wait(0.01)
	tool:Destroy()
	
end)

But the textbox's text doesn't change when edited. How can I get it?

1 answer

Your variable box stores the current text instead of the actual text box. If a variable is storing a property and the property is changed, the variable doesn't change with the property. Try:

local box = script.Parent.Parent.User --I removed the .Text
script.Parent.MouseButton1Click:Connect(function(player)
    local NewP = box.Text
    local tool = player.Character:FindFirstChildWhichIsA("Tool")
    local target = game.Workspace:FindFirstChild(NewP)
    tool:Clone().Parent = target
    wait(0.01)
    tool:Destroy()
end)

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