Script not printing any changed text in textbox

Probably an easy fix I’m just not seeing, attached is a script that is supposed to print the text of a textbox when a textbutton is clicked, however it only prints the text I send before testing

script.Parent.TextButton.MouseButton1Down:Connect(function()
	
	print(script.Parent.TextBox.Text)
end)
	

Is this a local script or a script?

If it’s a server script, change the RunContext of it to Client.
image

It’s Local since it’s parented to StarterGui. Or, somewhere in it.

oh my god, ive been stuck on this problem for 2 days, thank you

1 Like

Not necessarily, you can use both types of scripts in a GUI.

Interesting. Except, what’s the difference between a LocalScript and a Script that has RunContext set to Client?

There isn’t much difference, RunContext was added to make life easier for developers.

Check out the post Roblox made when it was released, they explain it in detail.

MouseButton1Down and similar events work on both server and local scripts. You only need them if you need the Activated event or to read from a TextBox, or for some higher input fidelity.

1 Like
CurrentText = ""

script.Parent.MouseButton1Click:Connect(function()
    print(CurrentText)
end)

script.Parent.Textbox.Changed:Connect(function()
    CurrentText = script.Parent.Textbox.Text
end)