How would i make a TextBox PlayerUpdatedText to copy to a Value?

Hello, I am @Owen_Hevalide2 and I have a basic question to ask

How would i make it so when a player types in my TextBox it saves to the Value inside the Text Box, so i can access what they typed through a script, to run a function to kick that player! Can I have any advice? I have provided a image showing what i am trying to do!

If you don’t understand it i will explain it here:
When you type in the TextBox and save it, it will copy what they typed and make the Value’s value to the thing they typed. This will be used in a Admin Panel where you can kick users.



Use a button and when the button is clicked do

local plr= game.Players:FindFirstChild(script.Parent.Text)
for i,v in pairs(game.Players:GetChildren()) do
if v == plr.Name then

Insert a local script into the TextBox:

script.Parent.Value.Value == script.Parent.Text

local plr = game.Players:FindFirstChild(script.Parent.Value.Value)
for i,v in pairs(game.Players:GetChildren()) do
    if v == plr.Name then

Look at the code that I sent, it’s inefficient to have a value when you can just take the text from the text box directly

I was just making a script to suit his desires, but yes, your script would be more efficient, if that’s the way you’re trying to go.


there’s a function to get all players, Players:GetPlayers() which is the canonical method you can suppose and…


Good attempt, but

why loop?

just kick the player directly by doing

 local player = game.Players[script.Parent.Text]
 if player then

this would prevent unnecessarily iterating and comparing each player (also your code would currently only compare a player object with a string instead of comparing the name, same with crusty’s code).

I suggest testing code to an extent too where possible before proposing it as a solution, to not confuse other developers.

1 Like

It is saying that you made some sort of error in your statement?

Who’s code did you use? Because there is 3 different ones here

Its giving me an error in the output, here is some footage.image

No, which code sample did you use?

I had no idea how to approach this idea, since i am new.

Which code sample did you use from above?

I had no idea how I could set this up, and i could not see how to do this on the internet ( and any way to learn it ) so i asked on the DevForum, so i had no code.

Either ways, both code samples were flawed.


Try to listen for the FocusLost event for the TextBox.

local StringValue = script.StringValue -- place a string value under this script, called StringValue
local Textbox = script.Parent -- place the LocalScript right under the text box

    local text = Textbox.Text
    if game.Players[text] then
       StringValue.Value = text -- each time focus was lost, set the value to the string value for whatever reason
1 Like