FruitsZ
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 25722 |
|
|
| 13 Jul 2014 08:50 AM |
To make the doors open I would need to use a table correct ?
So the first peice would be:
script.Parent.Touched:connect(function(player) And then the script to check if it's a player
If hum then
|
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 08:57 AM |
No, you would not need to use a table, but it may be easier to use one like so:
local Doors = {Door1,Door2}
function OpenDoor(Door) Door.CFrame = Door.CFrame * CFrame.new(-0.1,0,0) -- whatever CFrame you find works end
for _, v in pairs(Doors) -- get children of Doors table OpenDoor(v) -- Open the door end |
|
|
| Report Abuse |
|
|
FruitsZ
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 25722 |
|
|
| 13 Jul 2014 09:06 AM |
Assuming I use only one door
And when a player hits a pad it moves left and opens slowly |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 09:36 AM |
| You can do the same, just use one 'object' in the table. |
|
|
| Report Abuse |
|
|
ezt12
|
  |
| Joined: 09 Jul 2014 |
| Total Posts: 1531 |
|
|
| 13 Jul 2014 09:36 AM |
If you're using only one door -
local door = Workspace.DoorPart local w = door.Size.X
local steps = 0 local int = 0.05
local debounce = false
function touched() debounce = true while steps < w do door.CFrame = CFrame.new(int, 0, 0) wait(0.1) steps = steps + int end debounce = false end
script.Parent.ClickDetector.MouseClick:connect(function() if debounce ~= true then touched() end end
That should work. |
|
|
| Report Abuse |
|
|
FruitsZ
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 25722 |
|
|
| 13 Jul 2014 09:55 AM |
| What does denounce do again? |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 11:57 AM |
| 'denounce' isn't an actual Lua term, it is just a variable holding a boolean value (true/false). We use a variable of this kind to create basic things, for example a door, open = true could be a value but you could also set open = false. |
|
|
| Report Abuse |
|
|
ezt12
|
  |
| Joined: 09 Jul 2014 |
| Total Posts: 1531 |
|
|
| 13 Jul 2014 04:45 PM |
Raver, I think you are slightly confused. He is asking what a debounce does.
I used a debounce to make sure that the door does not open too far. This could happen because when the player touches the door it does not wait for the door to close again before it calls the touched() function.
Basically, unless you have a walkspeed of 500, the time it takes you to walk through the door it will actually make the doors open at least 200 times, which will make the doors go 200x farther than we want them to.
The debounce tells the script that if the doors are still open, not to call the touched() function. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 05:19 AM |
| Exactly, that is what I stated. Debounce is basically a variable stating true or false, meaning true = door is open, ~= true/false = door is closed. |
|
|
| Report Abuse |
|
|
ezt12
|
  |
| Joined: 09 Jul 2014 |
| Total Posts: 1531 |
|
|
| 26 Jul 2014 09:37 AM |
| Wrong again :/ debounce = true does not mean that the door is open. It means that somebody recently stepped on the pad and not to execute the open() function until the doors are closed again. |
|
|
| Report Abuse |
|
|