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

How do I fix the infinite yield possible warning?

Asked by
Desmondo1 121
3 years ago

I'm trying to make a gamepass that gives you devil powers. The way I'm trying to do it is by making a folder in server storage and then putting all the local scripts for the powers in that and then cloning it into the player backpack.

Heres my code

ServerStorage = game:GetService("ServerStorage") local id = 13229693

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)

if purchased and id == ido then
    plr.Character.Humanoid.WalkSpeed = 20
end

end)

game.Players.PlayerAdded:Connect(function(plr)

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
    game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = 20 
    local Devil = ServerStorage:WaitForChild("Devil"):Clone()
    Devil.Parent = game.Players.LocalPlayer.BackPack


end

end)

0
WaitForChild(plr.Name) is the one that is giving you trouble. Remove it, since A. It's unnecessary, and B. It'll go on forever. Otherwise, just ignore since that scripts can continue even if the warning is present. Also you can't use LocalPlayer on a Server Script. Dovydas1118 1495 — 3y
0
Ok thanks but the script is working fine with the WaitForChild(plr.Name), and it says "Infinite yield possible on ServerStorage:WaitForChild("Devil") also if I can't use LocalPlayer on a ServerScript then how am I gonna clone it to whoever buys the gamepass? Desmondo1 121 — 3y
0
Nvm about the LocalPlayer stuff Desmondo1 121 — 3y

Answer this question