WaitForChild possibly not working and currently breaking my game

I was using the shift lock in the camera script but instead of it being a key to toggle I made it check a value. And I’m using WaitForChild to wait for that value to appear.
The value is already there yet the script is still waiting.

I print from the server side in order to confirm if the value truly isn’t there

And the server confirms that it’s there. Is WaitForChild just broken and is there a better alternative?

Edit : Works fine in studio but not in game.

1 Like

Every time a character spawns, the old Backpack instance is destroyed and a brand new one is created. Are you sure that’s not your issue?

No, since I haven’t even respawned yet, that’s the first life.

It’s possible it’s just making (and destroying) the Backpack twice for whatever reason. Try to connect a ChildAdded to the player and check if the name is Backpack.

well that’s not kind. Thanks for the help. It was creating it twice
image

2 Likes

I am positive that :WaitForChild() is working fine because there would be a Riot by now if it wasn’t.


To fix your problem;
Maybe you should put it somewhere else and not the Backpack?

Try putting the script in a Baseplate see what happens

I am 99% sure that it’s the Backpack not behaving well.

1 Like

WaitForChild works fine, it’s just that they’re using WaitForChild on an old Backpack instance. It’s an undocumented(?) feature of Backpacks that on character creation a brand new Backpack instance is created.

3 Likes