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

How do I make this GUI textbox's text change into a surfacegui's text?

Asked by 5 years ago

I'm trying to make a screen with an empty textlabel that will change when a GUI's text is inputted and a button is pressed. An example would be: I open a GUI and put in "Test", I then press a button and the word "Test" appears onto the Surfacegui.

local box = script.Parent.Parent.Box
local sa = workspace.screen.SurfaceGui.TextLabel
local sb = workspace.Screen.SurfaceGui.TextLabel
local enter = script.Parent

enter.Mousebutton1click:Connect(function()
    sa.Text = box.Text
    sb.Text = box.Text
end)

Thanks if you can help.

1 answer

Log in to vote
1
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago

You would need a reference to the SurfaceGui and the GUI where you are inputting text. Then, set the surface gui's text to whatever the input TextBox.Text is whenever the button is fired, or if you want to make it dynamically change then fire upon the TextBox.Changed event.

local screenGuiText = -- reference to the input text box
local surfaceGuiText = -- reference to the surface gui text label
local button = -- reference to the enter button for the input

button.MouseButton1Click:Connect(function()
    surfaceGuiText.Text = screenGuiText.Text
end)

-- or, for dynamic changing --
screenGuiText.Changed:Connect(function()
    surfaceGuiText.Text = screenGuiText.Text
end)

Hope this helps.

Ad

Answer this question