Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to put a textbox's text in a WaitForChild()?

So if I try doing this:

local text = script.Parent.Parent.TextBox.Text

script.Parent.MouseButton1Click:Connect(function()
if game.ReplicatedStorage.Maps:WaitForChild(text) == nil then
	print("Invalid")
	else
	print("valid")
end
end)

BUT I keep getting an infinite yield: Infinite yield possible on 'ReplicatedStorage.Maps:WaitForChild("")

How do I make it work without an infinite yield?

2 comments

0

?

0

You can't do :WaitForChild on a property.

2 answers

You are waiting for the child of Maps here.


if game.ReplicatedStorage.Maps:WaitForChild("Child's name"
) == nil then

3 comments

0

No i want it get the text from the textbox and use it it the "Child's name"

0

Wait, so you're saying you want to get the text from the inputted textbox and change the name with it?

0

yes

It looks like you're trying to see if a map is found matching the text in the textbox. The WaitForChild("") yields if it doesn't find a matching child. Instead, you can try this:

local text = script.Parent.Parent.TextBox.Text

local maps = game.ReplicatedStorage.Maps

script.Parent.MouseButton1Click:Connect(function()

for _, v in pairs(maps:GetChildren()) do

if string.lower(v.Name) == text 
then
print("Valid")
break
else
print("Invalid")
break

end
end
end)

sorry if this doesn't look nice, it is my first post

7 comments

0

Uh i keeps saying invalid when I put a correct name

0

It's case sensitive, maybe that's the problem?

0

no i copyed and pasted the name

0

try now, I edited the script

0

ok

0

still broken

0

I'm not really sure then, you could instead use textbuttons to open the map

This discussion is preserved as it was. New answers, comments, and votes are closed.