If player has no Cheeseburger

I want to make it check if the player has no cheeseburger but it doesn’t work and IDK if even checking if cheeseburger is nil works. Here is the script:

script.Parent.Triggered:Connect(function(player)
	print("works")
	local Cheeseburger = player:WaitForChild("Backpack"):WaitForChild("Cheeseburger")
	if Cheeseburger == nil then
		print("works")
	end
end)
script.Parent.Triggered:Connect(function(Player)
    if not player.Backpack:FindFirstChild("Cheeseburger") then
       print("player haz no chezburger")
    else
       print("player haz chezburger")
    end
end)

Hi, @OzeanSyler !

I think that the problem is that you’ve put WaitForChild() for local Cheeseburger. If the cheeseburger isn’t found, it will send this information on your output :

Infinite yield on player:WaitForChild("Backpack"):WaitForChild("Cheeseburger")

It will do so an infinite yield and so who says infinite yield says infinite wait. Better change the WaitForChild("Cheeseburger") to FindFirstChild("Cheeseburger").

I hope that my help was precious for you !

Best regards,

@Vikko151

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.