So if I try doing this:
1 | local text = script.Parent.Parent.TextBox.Text |
2 |
3 | script.Parent.MouseButton 1 Click:Connect( function () |
4 | if game.ReplicatedStorage.Maps:WaitForChild(text) = = nil then |
5 | print ( "Invalid" ) |
6 | else |
7 | print ( "valid" ) |
8 | end |
9 | 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?
You are waiting for the child of Maps here.
1 | if game.ReplicatedStorage.Maps:WaitForChild( "Child's name" |
2 | ) = = nil then |
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:
01 | local text = script.Parent.Parent.TextBox.Text |
02 |
03 | local maps = game.ReplicatedStorage.Maps |
04 |
05 | script.Parent.MouseButton 1 Click:Connect( function () |
06 |
07 | for _, v in pairs (maps:GetChildren()) do |
08 |
09 | if string.lower(v.Name) = = text |
10 | then |
11 | print ( "Valid" ) |
12 | break |
13 | else |
14 | print ( "Invalid" ) |
15 | break |
16 |
17 | end |
18 | end |
19 | end ) |
sorry if this doesn't look nice, it is my first post