Detect text in a textbox

  1. What do you want to achieve?
    im making a game where it generates parts, i made a textbox where you can type in the number/delay between part every spawns

  2. What is the issue? Include screenshots / videos if possible!
    the issue is the textbox doesnt put any text in property

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    no i have no solutions

VALUE MAKER SCRIPT (first attempt)

while wait(0.1) do
local setfff = game.StarterGui.settings.Frame.TextBox.Text

script.Parent.Value = setfff 
end

VALUE MAKER SCRIPT (second attempt)

local TextBox = script.Parent.Parent
TextBox:GetPropertyChangedSignal("Text"):Connect(function()
local setfff = tonumber(script.Parent.Parent.InputChanged)
script.Parent.Value = setfff
end)

please help me asap i wasted 1 hour on this

scripts are completly fine btw

What kind of script is this? If it’s a server script, the local edits to the Text property won’t replicate.

2 Likes
  1. Indent your Code (For readability purposes)
  2. U must use a RemoteEvent to change the value since the Server can’t see the changed value

i have no idea how to make that

I would take a look here, specifically the Client to Server in the RemoteEvents section.

1 Like

To understand that u must understand the server-client model. Since to stop Exploiters Roblox doesn’t allow Replication from Client to Server.

A RemoteEvent is used for Client-Server communication or vice versa. Whatever is changed on the client, the server cannot see (with very little exceptions). If this is a client-sided script, you will need to use a RemoteEvent to pass on the new value to the server.

game:GetService("ReplicatedStorage").RemoteEvent:FireServer(ParametersHere)

Then, on the server, you would do

game:GetService("ReplicatedStorage").RemoteEvent.OnServerEvent:Connect(function(player, Parameters) -- the first parameter is always the player
    -- do something
end)

Also, I will assume that what you’re trying to do is in a server script.

game.StarterGui.settings.Frame.TextBox.Text

Never do this. StarterGui is merely the gui that the player starts with, the default gui; any changes made to the gui by the player will not change inside StarterGui.

You could insert a LocalScript inside your gui and access the textbox from there:

local TextBox = script.Parent.Parent
TextBox:GetPropertyChangedSignal("Text"):Connect(function()
   local setfff = tonumber(script.Parent.Parent.InputChanged)
   script.Parent.Value = setfff
end)

(Exactly what you have done, except insert it in a LocalScript)

Then, if you want the server to be able to see the value that you changed, you need to send it through a RemoteEvent.

doesnt work… should i publish what ive done

Try changing

local setfff = tonumber(script.Parent.Parent.InputChanged)

To

local setfff = tonumber(TextBox.Text)

already did that, here is the model: https://www.roblox.com/library/5121117123/settings

Okay, I see the issue, you are setting the variable to what the value is at the start and it will not change. Here is the fixed code.

local val = script.delayy
while wait(tonumber(val.Value)) do
print("(generator): the value i see is"..val.Value)
local num = script.part
num.Value = num.Value +1
p = Instance.new("Part",workspace)
p.Size = Vector3.new(5,5,5)
p.Position = Vector3.new(-14.65, 161.47, -16.43)
p.Material = 'Glass'
p.Reflectance = 0.8
p.Transparency = 0.3
end

Note: I would recommend indenting your code. Also, I would recommend not using the 2nd argument of Instance.new() for performance reasons, but instead setting the parent after setting all of the properties. Here is a topic about it.

generator): the value i see is2 (x5) doesnt work

What do you mean it does not work? Is the part not being created?

the default value is 2 it doesnt change the value

wait it actually does but it doesnt apply

i will try to fix the issue alone i think i made a mistake

Oh wait, I see the issue now. You are setting the Value of delayy in a client script but trying to read it from a server script so the server script does not see the changes the client made. I would recommend using RemoteEvents to change the Value of delayy.

1 Like