Textbox Doesnt Change Value

Hi everyone, I recently had this issue where my textbox doesn’t work.

I tried everything from checking literally every property to reading to 10s and possibly spending 3 hours attempting to fix this. Assuming it would be easy. Well it wasn’t so I am here.

So as you can read from the title. I want this textbox when it’s focus is lost. To change its value, as well as check the text inputted to make sure it is an number and not a string and then use said value to change another value.

and here is my code

script.Parent.FocusLost:Connect(function(ep)
	if ep == true then
		if tonumber(script.Parent.Text) then
			game.ServerStorage.FlowRate.Value =  tonumber(script.Parent.Text) 
		end
	end


end)

Please help me, I would really appreciate it.

1 Like

Changing a value in ServerStorage from a local script is not possible, as the client cannot access server storage.

You want to use remote events.

Server Script:

local Remote = game:GetService("ReplicatedStorage"):WaitForChild("UpdateEvent")
local Value = game:GetService("ServerStorage"):WaitForChild("FlowRate")

Remote.OnServerEvent:Connect(function(player, value)
    if tonumber(value) then
        Value.Value = value
    end
end)

Client Script:

local Remote = game:GetService("ReplicatedStorage"):WaitForChild("UpdateEvent")
local TextBox = script.Parent

TextBox.FocusLost:Connect(function(enterPressed)
    if enterPressed == true then
        if tonumber(TextBox.Text) then
            Remote:FireServer(tonumber(TextBox.Text))
        end
    end
end)
1 Like

But this is on a server script, do I still need to do the remoteevent?

Oh hang out. I get it, damn. Time to try it out.

You want to handle the UI stuff from the client

1 Like

Hey i also wanna add that:

if tonumber(script.Parent.Text) then

might not even work, so consider changing it to:

if tonumber(script.Parent.Text) ~= nil then
1 Like

Just implimented this, it works. Thank you a LOT!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.