Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can someone help me with this script i made?

Asked by 11 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

i am very new (like really new) at lua scripting and i read some basics and this is the code i came up with

01function OnClicked(playerWhoClicked)
02game.Workspace.Doors.Door1.Transparency= 1
03game.Workspace.Doors.Door2.Transparency= 1
04game.Workspace.Doors.Door3.Transparency= 0
05game.Workspace.Doors.Door4.Transparency= 0
06game.Workspace.Doors.Door1.CanCollide= false
07game.Workspace.Doors.Door2.CanCollide= false
08game.Workspace.Doors.Door3.Cancollide= true
09game.Workspace.Doors.Door4.Cancollide= true
10wait(3)
11game.Workspace.Doors.Door1.Transparency= 0
12game.Workspace.Doors.Door2.Transparency= 0
13game.Workspace.Doors.Door3.Transparency= 1
14game.Workspace.Doors.Door4.Transparency= 1
15game.Workspace.Doors.Door1.CanCollide= true
16game.Workspace.Doors.Door2.CanCollide= true
17game.Workspace.Doors.Door3.Cancollide= false
18game.Workspace.Doors.Door4.Cancollide= false
19end

it doesn't work so can someone help me out? yes i know it's really bad

3 answers

Log in to vote
1
Answered by 11 years ago

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:

01function OnClicked(playerWhoClicked)
02game.Workspace.Doors.Door1.Transparency= 1
03game.Workspace.Doors.Door2.Transparency= 1
04game.Workspace.Doors.Door3.Transparency= 0
05game.Workspace.Doors.Door4.Transparency= 0
06game.Workspace.Doors.Door1.CanCollide= false
07game.Workspace.Doors.Door2.CanCollide= false
08game.Workspace.Doors.Door3.Cancollide= true -- Error. Has to be "CanCollide"
09game.Workspace.Doors.Door4.Cancollide= true -- Error. Has to be "CanCollide"
10wait(3)
11game.Workspace.Doors.Door1.Transparency= 0
12game.Workspace.Doors.Door2.Transparency= 0
13game.Workspace.Doors.Door3.Transparency= 1
14game.Workspace.Doors.Door4.Transparency= 1
15game.Workspace.Doors.Door1.CanCollide= true
View all 21 lines...

What your script should look like:

01H = game.Workspace.Doors -- I just added a little shortcut. It's optional if you want to add it. It just makes scripting easier.
02 
03function OnClicked(playerWhoClicked)
04H.Door1.Transparency= 1
05H.Door2.Transparency= 1
06H.Door3.Transparency= 0
07H.Door4.Transparency= 0
08H.Door1.CanCollide= false
09H.Door2.CanCollide= false
10H.Door3.CanCollide= true -- Fixed grammar mistake
11H.Door4.CanCollide= true -- Fixed grammar mistake
12wait(3)
13H.Door1.Transparency= 0
14H.Door2.Transparency= 0
15H.Door3.Transparency= 1
View all 23 lines...

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.

0
Thanks for the help :D ChaoticCommando 5 — 11y
0
Your welcome Chaotic :D bloonblaster2000 55 — 11y
Ad
Log in to vote
0
Answered by 11 years ago

You forgot script.Parent.Clicked:connect(onClicked)

01function OnClicked(playerWhoClicked)
02game.Workspace.Doors.Door1.Transparency= 1
03game.Workspace.Doors.Door2.Transparency= 1
04game.Workspace.Doors.Door3.Transparency= 0
05game.Workspace.Doors.Door4.Transparency= 0
06game.Workspace.Doors.Door1.CanCollide= false
07game.Workspace.Doors.Door2.CanCollide= false
08game.Workspace.Doors.Door3.Cancollide= true
09game.Workspace.Doors.Door4.Cancollide= true
10wait(3)
11game.Workspace.Doors.Door1.Transparency= 0
12game.Workspace.Doors.Door2.Transparency= 0
13game.Workspace.Doors.Door3.Transparency= 1
14game.Workspace.Doors.Door4.Transparency= 1
15game.Workspace.Doors.Door1.CanCollide= true
View all 21 lines...
0
Also Do you have Door 1 - Door4? Roboy5857 20 — 11y
0
Robot, you still left the same grammar mistake in Chaotic's script, in which you let "Cancollide" stay as it is, even though it is supposed to be "CanCollide". bloonblaster2000 55 — 11y
0
Sorry, didn't noticed. And by the way... Roboy* Roboy5857 20 — 11y
Log in to vote
-1
Answered by 11 years ago
01function OnClicked(playerWhoClicked)
02game.Workspace.Doors.Door1.Transparency= 1
03game.Workspace.Doors.Door2.Transparency= 1
04game.Workspace.Doors.Door3.Transparency= 0
05game.Workspace.Doors.Door4.Transparency= 0
06game.Workspace.Doors.Door1.CanCollide= false
07game.Workspace.Doors.Door2.CanCollide= false
08game.Workspace.Doors.CanCollide= true
09game.Workspace.Doors.Door4.CanCollide= true
10wait(3)
11game.Workspace.Doors.Door1.Transparency= 0
12game.Workspace.Doors.Door2.Transparency= 0
13game.Workspace.Doors.Door3.Transparency= 1
14game.Workspace.Doors.Door4.Transparency= 1
15game.Workspace.Doors.Door1.CanCollide= true
16game.Workspace.Doors.Door2.CanCollide= true
17game.Workspace.Doors.Door3.CanCollide= false
18game.Workspace.Doors.Door4.CanCollide= false
19end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

--Put a ClickDetector in the brick + Keep name as ClickDetector

0
Oops sorry about the script.Parent.ClickDetector.MouseClick:connect(onClicked) thing not being in code. I accidentally put it out of the Code Block fireboltofdeath 635 — 11y
0
You took out the Door3 part in line 8. bloonblaster2000 55 — 11y
0
Err... fireboltofdeath 635 — 11y

Answer this question