In this normal script in serverscriptservice What I type in the text box won't go to the value weird part is that what I have the value to say for like 0 the textbox's text will say 0 but if I type anything into the textbox the value won't change.
local val = game.Workspace.Part.Value local box = plr.PlayerGui.ScreenGui.TextBox box.Text = val.Value val.Value = box.Text
Simple fix here.
When you type something into a textbox, it only changes in the client. This means the server has no access to see it.
If you need the server to see what is put in the textbox, I recommend you use a remote event. This allows you to communicate to the server from the client, or from the client to the server.
However, now you will need two scripts.
Your first script will need to be a local script. Inside the local script, you should have an event to be fired such as FocusLost
.
You will then need to fire the event using Event:FireServer()
. In the parameters of the events, you can put anything. For this we will put the text. Event:FireServer(script.Parent.Text)
.
So lets say you had the local script inside the textbox and the remote event called GetText in ReplicatedStorage
. The local script might look something like this:
script.Parent.FocusLost:Connect(function() game.ReplicatedStorage.GetText:FireServer(script.Parent.Text) end)
Now we need the server sided script to set the value. This will need to connect to when the remote event is fired through Event.OnServerEvent:Connect(function(Player, Text)
You need the 'Player' parameter here to show what player it is who fired it. You then need to do what you want to do with the code, such as set the value.
So finally, the server sided script ( normal script) might say:
local val = game.Workspace.Part.Value game.ReplicatedStorage.GetText.OnServerEvent:Connect(function(Player, Text) val.Value = Text end)