I use this script
local TimesClicked = 0 script.Parent.mouseClick:connect(function(Player) if script.Parent.Parent.CanCollide == true then Player.leaderstats.LifeFormFound.Value = Player.leaderstats.LifeFormFound.Value +1 TimesClicked = TimesClicked +1 if TimesClicked == 1 then script.Parent.Parent.Transparency = 1 script.Parent.Parent.CanCollide = false wait(3) script.Parent.Parent.Transparency = 0 script.Parent.Parent.CanCollide = true end end end)
for the first time, it works but when I click the brick the second time it did not turn invisible
So the code Should be
local TimesClicked = 0 script.Parent.mouseClick:connect(function(Player) if script.Parent.Parent.CanCollide == true then Player.leaderstats.LifeFormFound.Value = Player.leaderstats.LifeFormFound.Value +1 TimesClicked = TimesClicked +1 if TimesClicked ~= 0 and TimesClicked ~= nil then script.Parent.Parent.Transparency = 1 script.Parent.Parent.CanCollide = false wait(3) script.Parent.Parent.Transparency = 0 script.Parent.Parent.CanCollide = true end end end)
First of all I would like to note that your code is not indented. Well indented code is necessary for spotting errors before they happen and code readability. The reason you are unable to make it work the second time is because on line 5 you are turning TimesClicked to TimesClicked + 1 every time the event is fired. Because of that line 6 will never get past that == 1 again. Hope this helps and have a great day scripting.