How to do: SurfaceGui TextBox > ReplicatedStorage Value

I have a TextBox in a SurfaceGui (in a part of course) in workspace. I want the input from the TextBox to be processed into a value and put in a ReplicatedStorage Value (instance).

I have tried SO many solutions - FocusLost, Events, Changed, LocalScript/Script and nothing seems to be working.

How would I do this?
If anything is unclear, please let me know!

4 Likes

Is there an error? what’s the current script?

3 Likes

So if i’m correct, you wanna convert text to value?

you can do tonumber(TextBox.Text) or tostring(TextBox.Text)

--number

local TextBox = -- path to textbox
local Value = -- path to ur value
TextBox.FocusLost:Connect(function(gp)
  if gp then
    Value.Value = tonumber(TextBox.Text)
  end
end)
2 Likes

I think he wants to make the TextBox Text be put into a value

1 Like

Worst thing that could happen - empty output logs unfortunately.

1 Like

Well it depends on what type of value he is using.

2 Likes

Tried this earlier and just now, doesn’t work.

1 Like

What is the type of Value you’re using

1 Like

Considering you’re using a stringvalue

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local textBox = path_to_textbox
local value = ReplicatedStorage.Value

textBox.FocusLost:Connect(function()
       value.Value = textBox.Text
end)
1 Like

I’m using string value.

This one doesn’t work.
I’m wondering, since with normal TextBoxes in GUIs, you would use LocalScripts, what would I do here?

1 Like

It can be a LocalScript, yeah but if you want the value to be replicated to the server use a RemoteEvent.

1 Like

Maybe this will show more what I want to do.

1 Like

Tried already aswell. Nothing seemed to be picked up or anything though. I placed a bunch of print functions all over but weirdly enough, there still were no in the output log.

1 Like

Do you want anyone to edit this and it will be replicated to everyone or just the local client?

1 Like

It’s a 1 player server, so doesn’t quite matter I think.

RemoteEvents don’t seem to work either.

1 Like

What’s your script? can you share it?

1 Like

Takes the Event (in ServerScriptService)

local event = game.ReplicatedStorage.PlaneStats.Update

event.OnServerEvent:Connect(function(text)
	game.ReplicatedStorage.PlaneStats.PlaneInfo.TailNumber.Value = tostring(text)
end)

Sends the Event (in the textbox in surfacegui)

local value = game:GetService("ReplicatedStorage").PlaneStats.PlaneInfo.TailNumber
local text = script.Parent.Text

script.Parent.FocusLost:Connect(function()
	game:GetService("ReplicatedStorage").PlaneStats.Update:FireServer(text)
end)
1 Like

Is your LocalScript in workspace? If so, it won’t run

1 Like

I believe the SurfaceGui has to be in the PlayerGui (so you put it in StarterGui) in order for it to work. You then just have to set the adornee to the part you want, which can be done in the properties tab.

Note that you have to record the value of the textbox with a local script and send it to the server with a remote.