How can I edit the text of a text label from a TextBox?

Alright so I’m trying to create something so when you insert your business name into the text box and once you click create it changes the the text of another TextLabel to the name (Text of the TextBox) of there business. How can I program this? Example Below

2 Likes

TextBox API

You should look into FocusLost. The API even gives an example.

1 Like

I looked into TextBox API and Im still pretty confused

assuming the local script is in the text button


--client

script.Parent.MouseButton1Click:Connect(function()
--[[remote here]]:FireServer(--[[textbox]].Text)
end)

--server
--[[remote]].OnServerEvent:Connect(function(plr,text)
--[[text label]].Text = ("Current Business: ".. text)
end)

1 Like

Use .Activated instead of MouseButton1Click or you will get angry mobile/XBox players.

Also, instead of a RemoteEvent, you should use a RemoteFunction because the player needs to know whether or not the Server accepted the business name (since it needs to be filtered for bad words using Chat:FilterStringForBroadcast()).

On the Server, there will be a function like:

RemoteFunction.OnServerInvoke = function(player, text)
    text = game:GetService("Chat"):FilterStringForBroadcast(text, player)
    return text
end
2 Likes

alright, not sure if im dumb but I dont see anything wrong with this… if there is please let me know

the server part is gonna be a script in serverscriptservice and u could also send the local label in the fireserver so do :FireServer(textbox.Text,label)

and OnServerEvent(plr,text,label) then it should work

wdym by “the server part is gonna be a script in serverscriptservice”? sorry if im annoying you

If you want to go the RemoteFunction route:
LocalScript

local textbox = DIRECTORY_HERE

script.Parent.Activated:Connect(function()
    local requestText = REMOTEFUNCTION_DIRECTORYHERE:InvokeServer(textbox.Text)
    if requestText then
        DIRECTORY_TO_BUSINESS_LABEL.Text = requestText
    end
end)

Server is what I wrote above.

first ur not annoying at all i love helping people.
But what i mean is ur going to want to make a script and put it in ServerScriptService so it can detect when a client fires the remote

1 Like

Set it up like this and put Server script code under ServerScriptStorage. Then put player code in LocalScript.
Capture

alright so I got the SSS code, but how do I connect it from the SSS code to the local script?

1 Like

so ur going to fire a remote from a local script when u do that a script can detect it so make a local script in the gui button and fire a remote in replicated storage use the SSS code to know when it was fired and get the locals the client sent

so the SSS script is gonna use .OnServerEvent:Connect(function(plr,text,label)

and the local script is gonna use :FireServer(text in the textbox,path to label)

textLabel.Text = "Hello"

simple as that

1 Like

thanks! But that’s not what I’m looking for

You should fire an event with the text in the box.

PS: Remember to filter the string on the server to avoid naughty names :wink:

sorry for the late response!! I get what your saying, I just dont know how I would format it, im trying to learn how to do this not copy so if you could give me a example that would be appreciated

still confused on how it would be formatted

I think you’d format it like this and put the variables in the boxes
Client is Local Script
Server is SSS stuff

while true do
wait(“0.1”)

YourTextlabelName.text = YourTextboxName.text

end