B_lron
(blair)
February 15, 2023, 5:17pm
#1
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)
Lostude
(Lostude)
February 15, 2023, 5:19pm
#2
Is this a local script or a script?
If it’s a server script, change the RunContext
of it to Client
.
Vanniris
(Vanni)
February 15, 2023, 5:21pm
#3
It’s Local since it’s parented to StarterGui. Or, somewhere in it.
B_lron
(blair)
February 15, 2023, 5:23pm
#4
oh my god, ive been stuck on this problem for 2 days, thank you
1 Like
Lostude
(Lostude)
February 15, 2023, 5:23pm
#5
Not necessarily, you can use both types of scripts in a GUI.
Vanniris
(Vanni)
February 15, 2023, 5:25pm
#6
Interesting. Except, what’s the difference between a LocalScript and a Script that has RunContext set to Client?
Lostude
(Lostude)
February 15, 2023, 5:30pm
#7
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.
Hey Developers,
We are excited to announce RunContext .
What is RunContext?
RunContext is a property of Script that allows you to control where it will run in your experience. Initially it has the following options but we may expand on them in the future:
Legacy - Scripts will run when parented to specific containers. This is identical to the current behavior many of you are used to and is the default for this property.
Server - Scripts will run anywhere in the place including services such …
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)