Clicking TextButton won't output TextBox text

Hello. I’m trying to make a system where a player inputs numbers into a TextBox and clicks a button to print those numbers. Everything is in StarterGui and the script is Local.

local TextButton3 = script.Parent
local Players = game:GetService("Players").LocalPlayer.PlayerGui
local TextBox = Players.TextBox

TextButton3.MouseButton1Click:Connect(function()
	local playerNumber = (TextBox.Text)
	print(playerNumber)
end)

pictures of explorer:
image

Any help and tips are appreciated.

2 Likes

You’re referring to your Textbox incorrectly. Instead of calling the ScreenGui “ChatBox1” and the Frame within it, you’re skipping both of those, which may cause an error. Replace your “TextBox” variable with the line of code below:

local Players = game:GetService("Players").LocalPlayer.PlayerGui
local TextBox = Players.ChatBox1.Frame.TextBox

Hope this helps.

Oops. I fixed the path and even then it doesn’t seem to print the input of the player. Could I just route the text from a TextBox function into a variable and then print the variable with a button press?

Right. Just came back to the problem a bit later and turns out I disabled client outputs in the output console. Oops

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.