Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

So if I try doing this:

1local text = script.Parent.Parent.TextBox.Text
2 
3script.Parent.MouseButton1Click:Connect(function()
4if game.ReplicatedStorage.Maps:WaitForChild(text) == nil then
5    print("Invalid")
6    else
7    print("valid")
8end
9end)

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

How do I make it work without an infinite yield?

0
? User#23252 26 — 4y
0
You can't do :WaitForChild on a property. AntiWorldliness 868 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

You are waiting for the child of Maps here.

1if game.ReplicatedStorage.Maps:WaitForChild("Child's name"
2) == nil then
0
No i want it get the text from the textbox and use it it the "Child's name" SpoostyGuy 18 — 4y
0
Wait, so you're saying you want to get the text from the inputted textbox and change the name with it? nekosiwifi 398 — 4y
0
yes SpoostyGuy 18 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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:

01local text = script.Parent.Parent.TextBox.Text
02 
03local maps = game.ReplicatedStorage.Maps
04 
05script.Parent.MouseButton1Click:Connect(function()
06 
07for _, v in pairs(maps:GetChildren()) do
08 
09if string.lower(v.Name) == text
10then
11print("Valid")
12break
13else
14print("Invalid")
15break
16 
17end
18end
19end)

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

0
Uh i keeps saying invalid when I put a correct name SpoostyGuy 18 — 4y
0
It's case sensitive, maybe that's the problem? Defectivethekiller1 72 — 4y
0
no i copyed and pasted the name SpoostyGuy 18 — 4y
0
try now, I edited the script Defectivethekiller1 72 — 4y
View all comments (3 more)
0
ok SpoostyGuy 18 — 4y
0
still broken SpoostyGuy 18 — 4y
0
I'm not really sure then, you could instead use textbuttons to open the map Defectivethekiller1 72 — 4y

Answer this question