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 3 years ago
Edited 3 years ago

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?

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

2 answers

Log in to vote
0
Answered by 3 years ago

You are waiting for the child of Maps here.


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

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

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

Answer this question