I'm trying to make a script that has a model become visible when you click a brick with a ClickDetector, then after 12 seconds it disappears. How do I make it so that I can click the block and it re-appears? I tried changing it a lot, but nothing worked.
visible = true
script.Parent.ClickDetector.MouseClick:connect(function()
if visible == true then
for i,v in pairs(script.Parent.Parent["SampleName"]:GetChildren()) do
v.Transparency = 0 -- 1 is for completely invisible
v.CanCollide = true
visible = true
end
end
wait(12) --this is used to make it disappear again 12 seconds after the lines above were ran
for i, v in pairs(script.Parent.Parent["SampleName"]:GetChildren()) do
v.Transparency = 1
v.CanCollide = false
visible = false
end
end)
--trying to get it so that after i click the brick, i can come back, click it again, and it works. it doesn't no matter how much i try to change the script to work.

4 comments
Nothing makes visible true again
And why do you have it so that when Visible = true, it will then make it visible??
Half way through providing a very thorough answer, I discovered your question makes no sense.
you are lacking knowledge of conditionals. I highly recommend referring to them, in the process of how they work.