i am very new (like really new) at lua scripting and i read some basics and this is the code i came up with
01 | function OnClicked(playerWhoClicked) |
02 | game.Workspace.Doors.Door 1. Transparency = 1 |
03 | game.Workspace.Doors.Door 2. Transparency = 1 |
04 | game.Workspace.Doors.Door 3. Transparency = 0 |
05 | game.Workspace.Doors.Door 4. Transparency = 0 |
06 | game.Workspace.Doors.Door 1. CanCollide = false |
07 | game.Workspace.Doors.Door 2. CanCollide = false |
08 | game.Workspace.Doors.Door 3. Cancollide = true |
09 | game.Workspace.Doors.Door 4. Cancollide = true |
10 | wait( 3 ) |
11 | game.Workspace.Doors.Door 1. Transparency = 0 |
12 | game.Workspace.Doors.Door 2. Transparency = 0 |
13 | game.Workspace.Doors.Door 3. Transparency = 1 |
14 | game.Workspace.Doors.Door 4. Transparency = 1 |
15 | game.Workspace.Doors.Door 1. CanCollide = true |
16 | game.Workspace.Doors.Door 2. CanCollide = true |
17 | game.Workspace.Doors.Door 3. Cancollide = false |
18 | game.Workspace.Doors.Door 4. Cancollide = false |
19 | end |
it doesn't work so can someone help me out? yes i know it's really bad
Oh, I see the problem. For the CanCollide properties in the script, you HAVE to uppercase CanCollide or else the script won't work. Lua is very sensitive and if you make even one grammar mistake in the script, it won't run.
Your script before:
01 | function OnClicked(playerWhoClicked) |
02 | game.Workspace.Doors.Door 1. Transparency = 1 |
03 | game.Workspace.Doors.Door 2. Transparency = 1 |
04 | game.Workspace.Doors.Door 3. Transparency = 0 |
05 | game.Workspace.Doors.Door 4. Transparency = 0 |
06 | game.Workspace.Doors.Door 1. CanCollide = false |
07 | game.Workspace.Doors.Door 2. CanCollide = false |
08 | game.Workspace.Doors.Door 3. Cancollide = true -- Error. Has to be "CanCollide" |
09 | game.Workspace.Doors.Door 4. Cancollide = true -- Error. Has to be "CanCollide" |
10 | wait( 3 ) |
11 | game.Workspace.Doors.Door 1. Transparency = 0 |
12 | game.Workspace.Doors.Door 2. Transparency = 0 |
13 | game.Workspace.Doors.Door 3. Transparency = 1 |
14 | game.Workspace.Doors.Door 4. Transparency = 1 |
15 | game.Workspace.Doors.Door 1. CanCollide = true |
What your script should look like:
01 | H = game.Workspace.Doors -- I just added a little shortcut. It's optional if you want to add it. It just makes scripting easier. |
02 |
03 | function OnClicked(playerWhoClicked) |
04 | H.Door 1. Transparency = 1 |
05 | H.Door 2. Transparency = 1 |
06 | H.Door 3. Transparency = 0 |
07 | H.Door 4. Transparency = 0 |
08 | H.Door 1. CanCollide = false |
09 | H.Door 2. CanCollide = false |
10 | H.Door 3. CanCollide = true -- Fixed grammar mistake |
11 | H.Door 4. CanCollide = true -- Fixed grammar mistake |
12 | wait( 3 ) |
13 | H.Door 1. Transparency = 0 |
14 | H.Door 2. Transparency = 0 |
15 | H.Door 3. Transparency = 1 |
So basically, your script only had 5 problems in it. To make the script really work, you have to add a ClickDetector into each of the parts, which are the doors.
Hope this helped! - Im new too bro.
You forgot script.Parent.Clicked:connect(onClicked)
01 | function OnClicked(playerWhoClicked) |
02 | game.Workspace.Doors.Door 1. Transparency = 1 |
03 | game.Workspace.Doors.Door 2. Transparency = 1 |
04 | game.Workspace.Doors.Door 3. Transparency = 0 |
05 | game.Workspace.Doors.Door 4. Transparency = 0 |
06 | game.Workspace.Doors.Door 1. CanCollide = false |
07 | game.Workspace.Doors.Door 2. CanCollide = false |
08 | game.Workspace.Doors.Door 3. Cancollide = true |
09 | game.Workspace.Doors.Door 4. Cancollide = true |
10 | wait( 3 ) |
11 | game.Workspace.Doors.Door 1. Transparency = 0 |
12 | game.Workspace.Doors.Door 2. Transparency = 0 |
13 | game.Workspace.Doors.Door 3. Transparency = 1 |
14 | game.Workspace.Doors.Door 4. Transparency = 1 |
15 | game.Workspace.Doors.Door 1. CanCollide = true |
01 | function OnClicked(playerWhoClicked) |
02 | game.Workspace.Doors.Door 1. Transparency = 1 |
03 | game.Workspace.Doors.Door 2. Transparency = 1 |
04 | game.Workspace.Doors.Door 3. Transparency = 0 |
05 | game.Workspace.Doors.Door 4. Transparency = 0 |
06 | game.Workspace.Doors.Door 1. CanCollide = false |
07 | game.Workspace.Doors.Door 2. CanCollide = false |
08 | game.Workspace.Doors.CanCollide = true |
09 | game.Workspace.Doors.Door 4. CanCollide = true |
10 | wait( 3 ) |
11 | game.Workspace.Doors.Door 1. Transparency = 0 |
12 | game.Workspace.Doors.Door 2. Transparency = 0 |
13 | game.Workspace.Doors.Door 3. Transparency = 1 |
14 | game.Workspace.Doors.Door 4. Transparency = 1 |
15 | game.Workspace.Doors.Door 1. CanCollide = true |
16 | game.Workspace.Doors.Door 2. CanCollide = true |
17 | game.Workspace.Doors.Door 3. CanCollide = false |
18 | game.Workspace.Doors.Door 4. CanCollide = false |
19 | end |
script.Parent.ClickDetector.MouseClick:connect(onClicked)
--Put a ClickDetector in the brick + Keep name as ClickDetector