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 10 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

function OnClicked(playerWhoClicked)
game.Workspace.Doors.Door1.Transparency= 1
game.Workspace.Doors.Door2.Transparency= 1
game.Workspace.Doors.Door3.Transparency= 0
game.Workspace.Doors.Door4.Transparency= 0
game.Workspace.Doors.Door1.CanCollide= false
game.Workspace.Doors.Door2.CanCollide= false
game.Workspace.Doors.Door3.Cancollide= true
game.Workspace.Doors.Door4.Cancollide= true
wait(3)
game.Workspace.Doors.Door1.Transparency= 0
game.Workspace.Doors.Door2.Transparency= 0
game.Workspace.Doors.Door3.Transparency= 1
game.Workspace.Doors.Door4.Transparency= 1
game.Workspace.Doors.Door1.CanCollide= true
game.Workspace.Doors.Door2.CanCollide= true
game.Workspace.Doors.Door3.Cancollide= false
game.Workspace.Doors.Door4.Cancollide= false
end

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 10 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:

function OnClicked(playerWhoClicked)
game.Workspace.Doors.Door1.Transparency= 1
game.Workspace.Doors.Door2.Transparency= 1
game.Workspace.Doors.Door3.Transparency= 0
game.Workspace.Doors.Door4.Transparency= 0
game.Workspace.Doors.Door1.CanCollide= false
game.Workspace.Doors.Door2.CanCollide= false
game.Workspace.Doors.Door3.Cancollide= true -- Error. Has to be "CanCollide"
game.Workspace.Doors.Door4.Cancollide= true -- Error. Has to be "CanCollide"
wait(3)
game.Workspace.Doors.Door1.Transparency= 0
game.Workspace.Doors.Door2.Transparency= 0
game.Workspace.Doors.Door3.Transparency= 1
game.Workspace.Doors.Door4.Transparency= 1
game.Workspace.Doors.Door1.CanCollide= true
game.Workspace.Doors.Door2.CanCollide= true
game.Workspace.Doors.Door3.Cancollide= false -- Error. Has to be "CanCollide"
game.Workspace.Doors.Door4.Cancollide= false -- Error. Has to be "CanCollide"
end

-- You forgot a part here. It's the most important part of the script.

What your script should look like:

H = game.Workspace.Doors -- I just added a little shortcut. It's optional if you want to add it. It just makes scripting easier.

function OnClicked(playerWhoClicked)
H.Door1.Transparency= 1
H.Door2.Transparency= 1
H.Door3.Transparency= 0
H.Door4.Transparency= 0
H.Door1.CanCollide= false
H.Door2.CanCollide= false
H.Door3.CanCollide= true -- Fixed grammar mistake
H.Door4.CanCollide= true -- Fixed grammar mistake
wait(3)
H.Door1.Transparency= 0
H.Door2.Transparency= 0
H.Door3.Transparency= 1
H.Door4.Transparency= 1
H.Door1.CanCollide= true
H.Door2.CanCollide= true
H.Door3.CanCollide= false -- Fixed grammar mistake
H.Door4.CanCollide= false -- Fixed grammar mistake
end

script.Parent.ClickDetector.MouseClick:connect(onClicked) -- This is the most important part of the script. It won't run without this.

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 — 10y
0
Your welcome Chaotic :D bloonblaster2000 55 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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

function OnClicked(playerWhoClicked)
game.Workspace.Doors.Door1.Transparency= 1
game.Workspace.Doors.Door2.Transparency= 1
game.Workspace.Doors.Door3.Transparency= 0
game.Workspace.Doors.Door4.Transparency= 0
game.Workspace.Doors.Door1.CanCollide= false
game.Workspace.Doors.Door2.CanCollide= false
game.Workspace.Doors.Door3.Cancollide= true
game.Workspace.Doors.Door4.Cancollide= true
wait(3)
game.Workspace.Doors.Door1.Transparency= 0
game.Workspace.Doors.Door2.Transparency= 0
game.Workspace.Doors.Door3.Transparency= 1
game.Workspace.Doors.Door4.Transparency= 1
game.Workspace.Doors.Door1.CanCollide= true
game.Workspace.Doors.Door2.CanCollide= true
game.Workspace.Doors.Door3.Cancollide= false
game.Workspace.Doors.Door4.Cancollide= false
end

script.Parent.Clicked:connect(onClicked)

0
Also Do you have Door 1 - Door4? Roboy5857 20 — 10y
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 — 10y
0
Sorry, didn't noticed. And by the way... Roboy* Roboy5857 20 — 10y
Log in to vote
-1
Answered by 10 years ago
function OnClicked(playerWhoClicked)
game.Workspace.Doors.Door1.Transparency= 1
game.Workspace.Doors.Door2.Transparency= 1
game.Workspace.Doors.Door3.Transparency= 0
game.Workspace.Doors.Door4.Transparency= 0
game.Workspace.Doors.Door1.CanCollide= false
game.Workspace.Doors.Door2.CanCollide= false
game.Workspace.Doors.CanCollide= true
game.Workspace.Doors.Door4.CanCollide= true
wait(3)
game.Workspace.Doors.Door1.Transparency= 0
game.Workspace.Doors.Door2.Transparency= 0
game.Workspace.Doors.Door3.Transparency= 1
game.Workspace.Doors.Door4.Transparency= 1
game.Workspace.Doors.Door1.CanCollide= true
game.Workspace.Doors.Door2.CanCollide= true
game.Workspace.Doors.Door3.CanCollide= false
game.Workspace.Doors.Door4.CanCollide= false
end

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 — 10y
0
You took out the Door3 part in line 8. bloonblaster2000 55 — 10y
0
Err... fireboltofdeath 635 — 10y

Answer this question