Unable to make chat() to use textbox.value as message

I am making radio system for my game, and i ran into a problem, that i cannot find way to make
ChatService:chat(radio, text, "White")
use textbox value as message.

I tried using "Message:"..text to make it work but what it did is make part say “Message:”. I also tried to search same issue, way to make it say value of textbox, and I found nothing.

2 Likes

Have you tried using textbox.text yet? In this post you only mentioned the value.

3 Likes

I have local text = textbox.text in script before line with :chat()

1 Like

wait did you type it this way or TextLabel.Text (with capital letters)?

local text = textbox.Text

ChatService:chat(radio, text, "red")

is the textbox a variable?

also can we maybe see the full script?

1 Like

What does it print when you run it? (Turn the code into a print)

1 Like

textbox is gui in starter gui.
``
local ChatService = game:GetService(“Chat”)

local radio = workspace.Radio
local textbox = script.Parent.TextBox
local button = script.Parent.TextButton

local text = textbox.Text
local used = radio.Used.Value

local using = false

button.MouseButton1Down:Connect(function()
if (not using and not used) then
using = true
used = true
radio.Sound:Play()
script.Parent.Sound:Play()
ChatService:chat(radio, text, “Red”)
wait(1)
used = false
wait(2)
using = false
end
end)
``

1 Like

uhhhh looks like lua didnt want to be full…

1 Like

there’s no event for the text box (focus lost and such)?

1 Like

looks like your problem is you’re only setting the text variable at the start of the script

Yeah, none. When i run the script with print(text) added in top of function, i get “message must non-empty” error on line that contains chat(), print also doesnt work

So i should move local text = textbox.Text in function?

yes you should move it into the function, should fix it

I tried and it did not fix, still says message must be non-empty.

Have you put text into the textbox?

Yep, on each test im sure to write text into textbox before pressing button to run script.

May we see the script? (30charrss)

It uses 2 scripts, so its better if i send file.
[file removed]

oh I see the issue, the script in the gui needs to be a local script to get player input from a textbox.