Can't reference something that exists?

I have literally been stuck on a problem that makes no sense to me. I’m referencing something inside a folder in RS, and it clearly exists, yet it still can’t be found. I’ve tried WaitForChild, FindFirstChild, and [name].

(Line 90)

The error is either (name) is not a valid member of (folder) or an infinite yield. The game also has plenty of time to load RS, since this isn’t immediately run. I don’t know how to solve this, and can any of you help me with this? (first post btw…)

1 Like

WaitForChild() function only accept objects so you have to write it like WaitForChild(template) instead of WaitForChild(template.Name).

That is actually Incorrect. It works with strings.

I’ve also tried stuff like folder[template.Name] (which i think works) and FindFirstChild. Neither work.

Can we see the full script? It May be somewhere else. Also are you attempting to recreate an item from a LocalScript inside of a GUI?

The rest of the script doesn’t really matter. The error is always on line 90. Also, the code shown can probably be run alone.

Also, please provide where it is by screenshot ring the folder.

The script always matters. I’m checking for the simple things and I agree with the person below who asked to see where in the folder this script is.

Is Values a folder within StarterPlayer?

Inside PetFrame. (Values is a folder inside the player)

Maybe the template’s name is not spelled correctly. Could you make sure?

Additionally, if it yields using WaitForChild and you are 100% sure it already exists, maybe it might be some other aspect of your code (Ex: variables). I’ll look into this screenshot btw.

Try adding a print(template) right under the _,template loop

It probably won’t solve your problem, but I recommend setting a TimeOut number.

Pets:WaitForChild(template.Name, 10)

Also, do

while wait() do

end

instead of

while true do
   wait()
end

Template’s name is correct, and all of the pets exist in the folder.image

It just prints the pet’s name. (Ex. “Angel”)

1 Like

Is EquippedPet the name of the pet or a value storing the name of the equipped pet?

Could you put a wait on the script and check if angel is actually in RS before the script runs? If you are cloning it from somewhere it may not exist yet.

The second one. Stores the pet that the player has equipped.

1 Like

I assume the setViewport function uses the frame variable reference to put the pet into equippedpet And obviously the error is before that. Yeah one moment.
With all of us here we’ll get the answer in no time haha.

I used all four methods of referencing (Wait, Find, Brackets, and direct referencing), all printed that the pet exists.