Textbox wont update whenever a player types in it

Hello

I was creating a ban GUI which is a remote event, so when you press the GUI it fires an event that gets the text of a Textbox, but in the output it says this.

Infinite yield possible on 'Players:WaitForChild(“something”)

something is the original text, even if i type something else it still thinks the text its “something.”

We can’t really help if we don’t have the code you’re using, could you send us both the code relating to the textbox and the code relating to the remotevent?

This means you’re trying to find something in Players, but it can’t find it and will infinitly yeild.

I assume this TextBox Checks to see if the player exists, so try Players:FindFirstChild("something") instead.

Alright, here it is

code for the local script gui:

local REvent = script.RemoteEvent

script.Parent.Activated:Connect(function()
    REvent:FireServer()
end)

code for the script:

local textbox = script.Parent.Parent
local Input = textbox.Parent.TextBox

script.Parent.RemoteEvent.OnServerEvent:Connect(function()
    local player = game.Players:WaitForChild(Input.Text)
    if player then
	    player:Kick()
    end
end)

that just broke the entire script?

you are already setting up the variable instead you should do that:

local REvent = script.RemoteEvent
 local TextBox=    -----your text box here
script.Parent.Activated:Connect(function()
    REvent:FireServer(TextBox.Text)
end)

server script:

   script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, text)
    if game.Players:FindFirstChild(text) then
   local player = game.Players:FindFirstChild(text)
    player:Kick()
    end
 end)

It works! thank you so much for your help.

1 Like

You’re only firing the server when it’s activated, not changed to make it when it’s changed do this:

local REvent = script.RemoteEvent
local normText = script.Parent.Text

script.Parent.InputChanged:Connect(function()
    if script.Parent.Text ~= tostring(normText) then
        REvent:FireServer()
    end
end)

Still, I would suggest using @MrchipsMa 's solution though