Why does it say Infinite Yield possible on 'Punching Masters!:WaitForChild("leaderstats")'?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? i want it so when you click 5 times you can get 1 resources in leaderstats here is the ouput and explorer


heres explorer

  1. What solutions have you tried so far? i havent tried any cause i cant find any

So ive been making a game and for some reason i cant get it to give me resources please help! btw this is in a model so it could just be that

local click = script.Parent.ClickDetector
local value = script.Parent.Value
local resources = game:WaitForChild("leaderstats"):WaitForChild("Resources")

click.MouseClick:Connect(function()
		value.Value += 1
	if value.Value == 5 then
		resources.Value += 1
			script.Parent.Transparency = 1
			script.Parent.CanCollide = false
			wait(10)
			script.Parent.CanCollide = true
			script.Parent.Transparency = 0
			value.Value = 0
	end
end)

You’re doing it on the game instead of the player. You could do this instead


local click = script.Parent.ClickDetector
local value = script.Parent.Value

click.MouseClick:Connect(function(player)

local resources = player:WaitForChild("leaderstats"):WaitForChild("Resources")

		value.Value += 1
	if value.Value == 5 then
		resources.Value += 1
			script.Parent.Transparency = 1
			script.Parent.CanCollide = false
			wait(10)
			script.Parent.CanCollide = true
			script.Parent.Transparency = 0
			value.Value = 0
	end
end)

@workingongamessoon

1 Like

Thanks alot for helping ive tried it on every website

No problem glad i could help….