Tip:
Highlight text to annotate it
X
hello robloxians on youtube and welcome to this tuturial
my name is jasondekiller5 and today i will be showing you how to make a door that opens
when you touch it
first of all, you want to insert a part into the workspace.
like that
then, you need to
resize the part to the shape of your door.
like that...
maybe a bit big but that does not matter
then, inside the part you want to insert a script
like that...
and in the script you need to write the following:
function Ontouched()
Ontouched is not needed but we will use it for this tuturial.
then, "script.Parent.Transparency = 0.9"
that makes the door a little bit visible but still see through
and this acctually links from the script, to the parent, to it's transparency
then "script.Parent.CanCollide = false"
This links to the parents CanCollide function which is set on by default.
Do not forget to set the anchor property to true! otherwise your door will dissapear.
then, we will wait 3 seconds before closing the door again.
then "script.Parent.Transparency = 0"
returning the transparency to it's original state.
and "script.Parent.CanCollide = true"
making the door collidable again...
then "end"
and a reference:
"script.Parent.Touched:connect(Ontouched)"
this will check if the part is touched and then it will connect to the function named
"Ontouched".
you can change Ontouched into anything you want, just make sure that the names stay equal
to eachother.
So if you have like "HelloWorld" at the function the reference needs to say "HelloWorld" too
or your script will break
What it acctually does is it looks for the scripts parent and then it waits until it
gets touched.
When it gets touched, it will connect to the function named "Ontouched" and the function
named Ontouched will launch this sequence.
Now to test our script, we need to either press F6 or click tools->test->Play solo.
there we are.
let's test the door, we just walk up to the door, touch it, and see if it works.
Touch... YAY!
a little bit shady, but still visible. Then it comes back after 3 seconds.
everytime you touch it it will become walk-through again and you can't see it anymore, or just
see it a little bit.
you can set the transparency to whatever you want.
This is it for this tuturial I hope you enjoyed it and learned from it, I will see you next
time.