|
| 21 Nov 2015 05:55 AM |
Is there any way of making a door that you have to be touching the Door and Clicking a button at the same time to open the Door?
This is the code I currently have.
function tch(h) if script.Parent.Parent.Button.ClickDetector.MouseClick:connect() then script.Parent:CanCollide = false wait(5) script.Parent:CanCollide = true end end
script.Parent.Touched:connect(tch) |
|
|
| Report Abuse |
|
|
UgOsMiLy
|
  |
| Joined: 15 Sep 2009 |
| Total Posts: 2095 |
|
|
| 21 Nov 2015 06:29 AM |
function tch(h) script.Parent.Parent.Button.ClickDetector.MouseClick:connect(function(p) script.Parent:CanCollide = false wait(5) script.Parent:CanCollide = true end) end
script.Parent.Touched:connect(tch)
(I think) |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2015 06:50 AM |
Did not work :(
Oh yeah I replaced the :CanCollide with a .CanCollide (Error I made Lol) |
|
|
| Report Abuse |
|
|
Metology
|
  |
| Joined: 06 Oct 2014 |
| Total Posts: 3255 |
|
|
| 21 Nov 2015 07:24 AM |
| U just said a function that hasn't even been recognized yet... |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2015 07:30 AM |
| Never seen a Function in a Function before.. But anyway, Help anyone? |
|
|
| Report Abuse |
|
|
RoKjell
|
  |
| Joined: 22 Nov 2012 |
| Total Posts: 1205 |
|
|
| 21 Nov 2015 07:38 AM |
I'm not giving the script but I'll explain how you can do this. That way you learn something by doing it yourself.
You can make touch (Touched) function which sets a certain value to true and another function that when you're not touching (TouchEnded)it anymore, it changes back to false. Then you use the click function which will check if it's true, and if it's true it will do what you want.
Error 666: Error not found. |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2015 07:41 AM |
Touching = false for _,v in pairs(Character:GetTouchingParts()) do Touching = true end
Button.ClickDetector.MouseClick:connect(function() if Touching then print'Touching Door and Clicked Brick' else print'Character not touching door' end end) |
|
|
| Report Abuse |
|
|
| |
|