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