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

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

Asked by 4 years ago

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?

0
Use tostring it converts a string to a stringvalue JesseSong 3916 — 4y
0
So how would I do that? co_existance 141 — 4y
0
Try putting it at line 2 JesseSong 3916 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

Basically, you are accessing the StarterGuiwhile 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
0
I want it to show to everyone in the server. co_existance 141 — 4y
0
Then you will have to use a remote event https://developer.roblox.com/en-us/api-reference/class/RemoteEvent TiredMelon 405 — 4y
0
Okay, thanks. co_existance 141 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question