Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to set a string value as a text box text?

I'm making a GUI where you type in some text into a text box, and then when you press the "submit" button it sets the text in that text box to a string value inside of the starter GUI. The problem is when you press the submit button, it changes the value to blank even though there is stuff inside of the text boxes. This is the script that I'm using.

script.Parent.MouseButton1Click:Connect(function()
	game.StarterGui.value1.Value = script.Parent.Parent.textbox.text
end)

and in the text label there is

while wait(1) do
	script.Parent.Text = game.StarterGui.value1.Value
end

Can someone help?

3 comments

0

Use tostring it converts a string to a stringvalue

0

So how would I do that?

0

Try putting it at line 2

2 answers

✓ Accepted answer

Basically, you are accessing the StarterGui while every player has their own PlayerGui in Roblox! Just add the PlayerGui to the script and make sure you use proper capitalization!

local player = game.Players.LocalPlayer
local playerGui = Player.PlayerGui
script.Parent.MouseButton1Click:Connect(function()
 playerGui.value1.Value = script.Parent.Parent.textbox.Text
end)

----------------------------------------------------------------
-- And your code in the textlabel
local player = game.Players.LocalPlayer
local playerGui = Player.PlayerGui
while wait(1) do
    script.Parent.Text = playerGui.value1.Value
end

3 comments

0

I want it to show to everyone in the server.

0
0

Okay, thanks.

The main problem that I see is that you are changing the starterGUI, which is different from the player gui, so you would need to tweak your code a little bit to look like this:

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.PlayerGui.value1.Value = script.Parent.Parent.textbox.text
end)

--text label text--

while wait(1) do
    script.Parent.Text = game.Players.LocalPlayer.PlayerGui.value1.Value
end

This discussion is preserved as it was. New answers, comments, and votes are closed.