Door = game.Workspace.Wall function pie() if Door.Transparency == 1 then Door.Transparency = 0 else Door.Transparency = 1 end end script.Parent.ClickDetector.MouseClick:Connect(pie)
"script.Parent.ClickDetector.MouseClick:Connect(pie)"
Why cant we put it in front? v(Like that?)v
Door = game.Workspace.Wall script.Parent.ClickDetector.MouseClick:connect(function() if Door.Transparency == 1 then Door.Transparency = 0 else Door.Transparency = 1 end end
Your going in the right direction, you can put it INFRONT. BUT I know why your code didn't work.. When you're putting the Event & function in front (basically the same as saying when you're putting script.Parent.ClickDetector.MouseClick:Connect() in front so don't get confused)
You forgot to add something, very small, a very small mistake. Make sure to put the script inside the door and put the clickdetector in the door which I think you already had and the script will work! :D
The small mistake you forgot to add was "end)" with the one bracket on the end. It's like that when you put the Event & function in front
local Door = script.Parent local cooldown = 2 -- how many seconds till they can click it again to avoid spamming the door local e = true script.Parent.ClickDetector.MouseClick:connect(function() if Door.Transparency == 1 and e == true then e = false Door.Transparency = 0 wait(cooldown) e = true elseif Door.Transparency == 0 and e == true then e = false Door.Transparency = 1 wait(cooldown) e = true end end) -- that small mistake you forgot to add, I replaced "end" to "end)"