TextButton Text transferring to TextBox not working

Hello! I am trying to make it so when I click a TextButton the text on the TextButton will transfer or show up in the TextBox. But for some reason nothing is working if anyone can help me I’d appreciate it!

What I have tried

  local button = script.Parent
  local TextBox = script.Parent
  button.MouseButton1Click:Connect(function()
  button.Text = TextBox.Text
  end)
2 Likes

why is button = script.Parent but textbox is also script.parent?

1 Like

Because if the Textbox isn’t there the Textbox.text would just error out

could you show me where the script is located?

You should use Remote Event. Text in textbox is only for local scripts.

textbox should be,

script.Parent.Parent.TextBox

Yes it does work but the TextButton text now disappears

local button = script.Parent
local TextBox = script.Parent.Parent.TextBox
button.MouseButton1Click:Connect(function()
button.Text = TextBox.Text
end)

lemme check this out hold on I’ll see what I can do.

put remote event in button named “RemoteEvent”

-- local script in button
script.Parent.MouseButton1Click:Connect(function()
   script.Parent.RemoteEvent:FireServer(script.Parent.Text)
end)

 -- normal script in textbox 
 script.Parent.Parent.TextButton.RemoteEvent.OnServerEvent:Connect(function(plr,text)
   script.Parent.Text = text
 end)

or just make like this:

script.Parent.MouseButton1Click:Connect(function()
   script.Parent.Parent.TextBox.Text = script.Parent.Text
end)
2 Likes

Thank you it worked perfectly!

1 Like