Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix 'infinite yield' on playerscripts for a player?

Asked by 4 years ago

When I try and use the code below with the for loop it teleports the player.

for i,plr in pairs(Players) do
        if plr.Character.HumanoidRootPart then
            if plr.Name == PlayerName then
               print("This is the player!")
               character = plr.Character
               if character then
                  -- Teleport Them
                  character:FindFirstChild("HumanoidRootPart").CFrame = PhoneFriendSpawn.CFrame + Vector3.new(0,10,0)
                  local MasterControl = require(plr:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
                  MasterControl:Disable()

But it stops on MasterControl and comes out with this output below.

11:50:17.813 - Infinite yield possible on 'Players.sonicfoo3:WaitForChild("PlayerScripts")'

What have I done wrong?

0
Are there any other error's happening in the console? An Infinite yield possible on a script just means that it could get stuck in an infinite loop, if you really think that the script is broken because of the infinite yield, usually :WaitForChild can cause one because it will wait for the child, and if it doesn't find it, then it will be stuck trying to find it. SillyDamien 11 — 4y
0
There are no other errors in the output. sonicfoo3 19 — 4y
0
Infinite yield on :WaitForChild simply means that it wasn't able to find "PlayerScripts". ScuffedAI 435 — 4y

Answer this question