I want to make a door open from a click and go transparent, I have that part covered. Though I need help on making it close 1 or 2 seconds after the click. Please help... Below is my code.
Door = script.Parent
function onClicked() Door.Transparency=.6 Door.CanCollide=false end
Door.ClickDetector.MouseClick:connect(onClicked)
if Door.ClickDetector.MouseClick:connect(onClicked) then wait(2) Door.Transparency=0 Door.CanCollide=true end
I personally can't read random code. Use a code block. You've been here long enough, and I know you've been told this before.
Here's your code in a code block,
01 | Door = script.Parent |
02 |
03 | function onClicked() |
04 | Door.Transparency = . 6 |
05 | Door.CanCollide = false |
06 | end |
07 |
08 | Door.ClickDetector.MouseClick:connect(onClicked) |
09 |
10 | if Door.ClickDetector.MouseClick:connect(onClicked) then |
11 | wait( 2 ) |
12 | Door.Transparency = 0 |
13 | Door.CanCollide = true |
14 | end |
It looks to me like you found a free model, tried to edit it, failed, and came here. Maybe not though. I'm just telling you what it looks like.
Just move the code in the conditional statement into the function "onClicked"
01 | local Door = script.Parent |
02 |
03 | function onClicked() |
04 | Door.Transparency = . 6 |
05 | Door.CanCollide = false |
06 | wait( 2 ) |
07 | Door.Transparency = 0 |
08 | Door.CanCollide = true |
09 | end |
10 |
11 | Door.ClickDetector.MouseClick:connect(onClicked) |
Good Luck