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

How do I set this TextLabel to a TextBox input?

Asked by 5 years ago

This is a LocalScript which is inside of a TextButton.

01local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
02 
03 
04local n = playerGui.OrderGui.Scroll.Name.TextBox.Text
05 
06function leftClick()
07    print("Left mouse click")
08    playerGui.OrderGui.CurrentOrder.Text = "Vanilla Milkshake by "..n
09end
10 
11script.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

Log in to vote
0
Answered by
7z99 203 Moderation Voter
5 years ago

Hello!

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

1local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
2 
3function leftClick()
4    local n = playerGui.OrderGui.Scroll.Name.TextBox.Text -- Move this inside the function so it gets updated to the textbox's current text.
5    print("Left mouse click")
6    playerGui.OrderGui.CurrentOrder.Text = "Vanilla Milkshake by "..n
7end
8 
9script.Parent.MouseButton1Click:Connect(leftClick)
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' MinecraftButterfly87 10 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question