generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: So I'm trying to make two doors open when a pad is touched

Previous Thread :: Next Thread 
FruitsZ is not online. 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
RaverKiller is not online. RaverKiller
Joined: 09 Jul 2014
Total Posts: 219
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 is not online. 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
RaverKiller is not online. RaverKiller
Joined: 09 Jul 2014
Total Posts: 219
13 Jul 2014 09:36 AM
You can do the same, just use one 'object' in the table.
Report Abuse
ezt12 is not online. 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 is not online. FruitsZ
Joined: 22 Jan 2013
Total Posts: 25722
13 Jul 2014 09:55 AM
What does denounce do again?
Report Abuse
RaverKiller is not online. RaverKiller
Joined: 09 Jul 2014
Total Posts: 219
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 is not online. 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
RaverKiller is not online. RaverKiller
Joined: 09 Jul 2014
Total Posts: 219
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image