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

How do I set this TextLabel to a TextBox input?

This is a LocalScript which is inside of a TextButton.

local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")


local n = playerGui.OrderGui.Scroll.Name.TextBox.Text

function leftClick()
	print("Left mouse click")
	playerGui.OrderGui.CurrentOrder.Text = "Vanilla Milkshake by "..n
end

script.Parent.MouseButton1Click:Connect(leftClick)

When I remove the ..n part it works fine, but nothing happens when I click the button when it has the ..n part in it.

(Excuse me as I was tired when I wrote this, I can go into further detail if you ask)

2 answers

Hello!

While I'm not 100% familiar with Lua textboxes, I believe I see your issue.

local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")

function leftClick()
    local n = playerGui.OrderGui.Scroll.Name.TextBox.Text -- Move this inside the function so it gets updated to the textbox's current text.
    print("Left mouse click")
    playerGui.OrderGui.CurrentOrder.Text = "Vanilla Milkshake by "..n
end

script.Parent.MouseButton1Click:Connect(leftClick)

1 comment

0

I got an error message when I removed the ..n part. I did it for testing purposes. Here it is: Players.MinecraftButterfly87.PlayerGui.OrderGui.Flavour.Vanilla.LocalScript:5: attempt to index nil with 'Text'

Because the TextBox was inside a frame called "Name," and "Name" is a property, that's what caused the issue.

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