Why does WaitForChild() yield even though the playerScripts is there

plr:WaitForChild("PlayerScripts"):WaitForChild("AdminCommands").Disabled = false

This code should enable a code in the players playerscripts but it prints this

Infinite yield possible on 'Players.EHGTR1903:WaitForChild(“PlayerScripts”)

out and doesn’t work. I thought of using remote events but I want to use this. How can I make this work?

1 Like

It seems like you’re trying to do this on the Server side, when PlayerScripts only exists on the Client.

Server:
image

Client:
image

Also, you can add a cutoff time for WaitForChild. Example being: plr:WaitForChild(“PlayerScripts”, 5) would attempt waiting for it for 5 seconds, and then giving up 5 seconds afterwards.

6 Likes