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?
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
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