Why its not working?

Im trying to do a script that once the player clicked a part 3 times it print Secret Unlocked but its not working

image

Full script

local script : ( working all good )

Workspace :
image

the detect script :
image

this is a serverscript inside a clickdetector right

Please provide me all of the code so i can help.

Did you add a something related to clicking? Such as:

script.Parent.ClickDetector.MouseClick:Connect (function()

Your question is confusing and does not really make much sense. Could you be more specific?

You should post the whole script and have it show the activated by a MouseClick event/function, or at least explain the context this is under.

Ok so here

local script :

Workspace :
image

script :
image

I just edited the post i tried my best to be specific

Are there any errors in the output?

No there is no error in the output

You could try:

function onClicked()
    workspace.Room.Handle1.CFrame = workspace.Room.Handle1.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 1)
    workspace.Secret.Cogs.Value += 1

    if workspace.Secret.Cogs.Value == 3 then --checks it each time a player clicks
        print("Secret Unlocked")
    end
end

workspace.Part1.ClickDetector.MouseClick:Connect(onClicked)

Use this all in one server script. Also, please use :Connect instead of :connect because it is deprecated, and doing something.Value = something.Value + 1 is the same thing as something.Value += 1.

1 Like

This only runs once when the game starts. Instead, do:

script.Parent.Changed:Connect(function(Value)
	if Value == 3 then
		print("Secret unlocked")
	end
end)
1 Like

Thank you it worked!!! :slight_smile:

It also worked but i cant mark 2 post as solution ty! :slight_smile: