How do you make a player click 4 times then makes object's transparency 1

So I am trying to make a script. When you click on the object 4 times you won’t be able to click anymore, but when I click it, it only makes me click 1 time. How do I fix the script?

Script:

ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
	print("Clicked!") 
	A.Transparency = 1
	B.Transparency = 1
	C.Transparency = 1
	GivePart.ClickDetector.MaxActivationDistance = 0
	local CupClone = Cup:Clone()
	CupClone.Parent = PlayerWhoClicked.Backpack 
end)

What do you mean “makes” you click? Like you have to click 4 times in order for it to activate, or the game automatically clicks for you?

Yes like that. Sorry if it doesn’t make sense

localscript since the variables will go for all users in the game if its a server script.

local amntClicked = 0
ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
	print("Clicked!") 
	amntClicked += 1
        if amntClicked >= 4 then
            A.Transparency = 1
            B.Transparency = 1
            C.Transparency = 1
	    GivePart.ClickDetector.MaxActivationDistance = 0
	    local CupClone = Cup:Clone()
	    CupClone.Parent = PlayerWhoClicked.Backpack 
        end
end)

Just a regular integer needed.

1 Like

When I reach the fourth click, it doesn’t give me the cup.

1 Like

Cup:Clone() is correctly Instanced?
The code @greatneil80 gave u, looks like working perfect.
Debbug by print(CupClone.ClassName)