I’m trying to make my TextBox’s Text to copy over to my TextLabel’s Text (When I type something in the TextBox it transfers to the TextLabel after I click “Enter”)
I’ve tried many ways and none were working, this is my current script:
local InputBox = game.StarterGui.ScreenGui.InputBox
local OutputBox = game.StarterGui.ScreenGui.OutputBox
InputBox.FocusLost:Connect(function(PressedEnter)
if PressedEnter then
OutputBox.Text = InputBox.Text
end
end)
I’ve tried looking through the devforum, and tried the scripts there, they didn’t work. I looked thorugh the devhub but it didn’t help either.
Use the Player’s PlayerGui instead of StarterGui, I assume this is that Localscript in your screengui, change it to this
local screenGui = script.Parent
local InputBox = screenGui.InputBox
local OutputBox = screenGui.OutputBox
InputBox.FocusLost:Connect(function(PressedEnter)
if PressedEnter then
OutputBox.Text = InputBox.Text
end
end)
StarterGui only holds the guis that are replicated to each player’s playerGui, you need to reference the guis in their PlayerGui
Anytime! if you have anymore issues don’t be afraid to make another post!
And PlayerGui is a child of a Player Instance, so you can’t find it via the explorer unless you’re doing an ingame test.
I was originally going to send this
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local screenGui = playerGui:WaitForChild("ScreenGui")
local InputBox = screenGui.InputBox
local OutputBox = screenGuiOutputBox
InputBox.FocusLost:Connect(function(PressedEnter)
if PressedEnter then
OutputBox.Text = InputBox.Text
end
end)
But then I saw that the localscript is a child of the ScreenGui, so I made it simpler for you, but both do the same thing, one just uses the fact it’s already in the PlayerGui so it just uses indexing, and the other gets the PlayerGui and then references the ScreenGui
Also, the LocalPlayer property is only useable in Localscripts, using it in regular scripts will return nil/nothing