Hello! Could someone help me?
I have four images where two are the same (memory game) and I would like to remove them from the scene when the same images are clicked, so I did this function.
local function clicked( event ) if (click1 == nil) then click1 = event.target.id name1 = event.target.name else click2 = event.target.id name2 = event.target.name print ("Tap: " .. click2) if (click1 == click2) and (name1 ~= name2) then print("Equals") click1.isVisible = false -- the error is on this line. click2.isVisible = false name1 = nil name2 = nil click1 = nil click2 = nil else print ("Error!") nome1 = nil nome2 = nil click1 = nil click2 = nil end end return true end
But I get an error when the clicks happen in the same pairs:
C:\memorygame\level1_1.lua: 54: attempt to index global ‘click1’ (a string value)
click1.isVisible = false – the error is on this line.