I’m trying to use WaitForChild() to wait until the object is loaded and continue with the script once it is.
The problem is that the object could have multiple names and I don’t know how to go about it.
So far I’ve tried WaitForChild(“PossibleName1” or “PossibleName2”), but it has not worked. Help would be greatly appreciated.
Maybe use for loops to check for the possible instances and keep waiting until the parts actually exist?
for i, v in pairs(workspace.Parts:GetChildren()) do
repeat task.wait() until v
-- Code here
If you are labeling items with similar names with just 1 different character at the end, you can use string.match to find a commonality. Here’s an example
local newPart = Instance.new("Part", game.Workspace)
newPart.Name = "Part1"
--As an example assume that you know the name contains the string "Part" but you
--don't know the number, here's what you can do:
This will halt the script until a new part is spawned into the workspace containing the string, “Part”. This allows you to name the parts anything you want as long as it includes "Part in it. So it could be anything from just “Part13456453345” to “dfgnjiunfhgdPartiuiiufghiojdf”
Let me know if you need anymore help