Hi, I want to make doors. I made a script that opens the door when a sign is clicked. The clickdetector and the script is inside the sign. They both are supposed to make another model inivisble. Can you tell me the issue with this code?
01 | function onClicked() |
02 | local children = game.Workspace.tardis 1 door:GetChildren() |
03 | for c = 1 , #children do |
04 | if children [ c ] .className = = "" |
05 |
06 | then children.Transparency = 1 |
07 | children.CanCollide = false |
08 | wait( 5 ) |
09 | children.Transparency = 0 |
10 | children.CanCollide = true |
11 |
12 |
13 | end |
14 | end |
15 | end |
16 |
17 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
Thanks
01 | function onClicked() |
02 | local children = game.Workspace.tardis 1 door:GetChildren() |
03 | for c = 1 , #children do |
04 | if children [ c ] .ClassName = = "" then |
05 | children [ c ] .Transparency = 1 |
06 | children [ c ] .CanCollide = false |
07 | wait( 5 ) |
08 | children [ c ] .Transparency = 0 |
09 | children [ c ] .CanCollide = true |
10 | end |
11 | end |
12 | end |
13 |
14 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
You needed the [c] after children to select the specific child. It should work now.
Do : (Instead of a clicked script,More efficient way of doing it is .Touched)
1 | script.Parent.Touched:connect( function (hit) |
2 | lc = game.Workspace.tardis 1 door:GetChildren() |
3 | lc.Transparency = 1 |
4 | wait( 5 ) |
5 | lc.Transparency = 0 |
6 | end ) |
Hope this helped.