Infinite yield possible on 'Players.MapleYT12.PlayerGUI.Character.Frame.Name.TextBox:WaitForChild("InputBox")

I’m gonna be honest but the script is from a tutorial and it is supposed to pop the player’s inputted name above their head.

local Event = game:GetService(“ReplicatedStorage”):WaitForChild(“FilterMessage”)

local Input = script.Parent:WaitForChild(“InputBox”)
local Submit = script.Parent:WaitForChild(“Button”)

local Display = script.Parent:WaitForChild(“TextLabel”)

Submit.MouseButton1Down:Connect(function(buttonClicked)
local function buttonClicked()
if Input.Text ~= “” then
Event:FireServer(Input.Text)
end
end
end)

What I think the error is, is that roblox is trying to find something but isn’t there.

Edit 1: The script works but it creates the error

Can we see the Explorer (The structure of the Inputbox)?

If this is what you are referring to here (selected script is the script I am talking about) image

You don’t need use WaitForChild for Input, Display and Submit.

Because there is no InputBox.

You do, sometimes assets don’t load and this could cause an error. If it was a Server Script, then you wouldn’t. That’s not his problem.

@MapleYT12 has their script inside of the UI elements. Shouldn’t the assets already be loaded by the time the script runs?

Can’t see their full explorer.

I would assume the selected script @MapleYT12 is referring too.

image

Just try putting a “,1” after all the “:WaitForChild("SomeObject")”, like :WaitForChild("SomeObject", 1)


Creates this problem

Nevermind, you can’t use MouseButton1Down on a TextBox instance.

Wouldn’t that just break his script? Since he wouldn’t have the object he’s trying to find?
I don’t think that resolves anything.

It’s giving Infinite yield because the script is trying to find an object that doesn’t exist, @MapleYT12 Try fixing the location of your objects and their names.
For example: If you’re trying to get the ‘Done’ TextButton you would:

local TextButton = script.Parent.Parent.Parent.Done

You could instead do this:

 local function buttonClicked()
          if Input.Text ~= "" then
                Event:FireServer(Input.Text)
          end
    end

Submit.MouseButton1Click:Connect(buttonClciked())

Tried this error still occurs,

I might re-write the entire script since this script was from a tutorial

I said to TRY it, if he doesn’t have the object then yes it won’t work. But I had this error recently and putting the wait in there fixed my issue so I thought it might be worthwhile for him to at least try.

Like this:
Submit.MouseButton1Click:Connect(MouseButton1Clicked())


Comes up with this problem
image

The issue here is the script trying to find an object that does not exist in the provided location.

As It says on Instance:WaitForChild:

Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.

You can fix this by fixing the location in the script.

Here the locations of the ‘Done’, ‘ImageLabel’, ‘Character’, ‘Name’ and TextBox I saw in your image:

local Frame = script.Parent.Parent.Parent
local Done = Frame.Done
local ImageLabel = Frame.ImageLabel
local Character = Frame.Character
local Name = script.Parent.Parent
local TextBox = script.Parent

You won’t be able to connect the MouseButton1Click to ‘Submit’ if Submit does not exist, so fix the locations and try the script.