Infinite yield possible on 'Workspace:WaitForChild("plr.Name")' Error

Hi, I’m making A Game pass for my game and there is an error Infinite yield possible on ‘Workspace:WaitForChild(“playerboygotswag2”)’ and it’s been bothering me for ours so I was hoping anyone could help me with my code. This is my code.

local id = 46151765

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido, purchased)
	if purchased and id == ido then 
		plr.Character.Humanoid.JumpPower = 100
	end
end)

game.Players.PlayerAdded:Connect(function(plr)
	
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, id)then
		 game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").JumpPower = 100 
	
	end
end)

please help.

You spelt “Himanoid” instead of “Humanoid”.
Always spell-check and proofread your code before running it. :slight_smile:

1 Like

oh, I did not notice thanks ill see if it works

ok i did it but it’s still giving the same error

May you send a picture of the error or what does it says?

Why are you going about this weird way to get the player’s humanoid? You already have the player from your PlayerAdded event, just change you code to something like this

game.Players.PlayerAdded:Connect(function(plr)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, id)then
		plr.CharacterAdded:Connect(function()
			plr.Character:WaitForChild("Humanoid").JumpPower = 100
			
		end)
	end
end)
1 Like

Just do plr.Character

You might have some other script that might have changed your character’s parent.

Thanks, it helped the error is gone.