How to make a TextBox show what another Textbox shows

I want text that is on one textbox to be cloned to another textbox.
How do i do it, and why does this script not work for this?

local nb = script.Parent.Parent.Parent.Parent:FindFirstChild("NicknameFrame").Nicknamebox

script.Parent.Text = nb.Text

This is only running once, you need a loop

and how do i do a loop?

1st way

local nb = script.Parent.Parent.Parent.Parent:FindFirstChild("NicknameFrame").Nicknamebox

nb:GetPropertyChangedSignal("Text"):Connect(function()
 script.Parent.Text = nb.Text
end)

2nd way

--Personally, the first one is better.
while task.wait() do
	local nb = script.Parent.Parent.Parent.Parent:FindFirstChild("NicknameFrame").Nicknamebox
	script.Parent.Text = nb.Text
end

Note: instead of getting too many parents, you can use FindFirstAncestor()

2 Likes

Didnt even know you could do it like that, you taught me something new! :grin:

1 Like
while task.wait() do
	local nb = script.Parent.Parent.Parent.Parent:FindFirstChild("NicknameFrame").Nicknamebox
	script.Parent.Text = nb.Text
end

I suggest you to do what @Valkyrop said, but .Changed sometimes gives error if it changes too many times.
To fix that store :GetPropertyChangedSignal("Text") connection into a variable then disconnect it then create a new connection.

local nb = script.Parent.Parent.Parent.Parent:FindFirstChild("NicknameFrame").Nicknamebox

local connection
function changeText()
    connection:Disconnect()
    script.Parent.Text = nb.Text
    connection = nb:GetPropertyChangedSignal("Text"):Connect(changeText)
end
nb:GetPropertyChangedSignal("Text"):Connect(changeText)