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: Click open Cframe door

Previous Thread :: Next Thread 
TrevorGaming99 is not online. TrevorGaming99
Joined: 25 Oct 2013
Total Posts: 241
05 May 2014 09:41 PM
I need help with a simple script that can be opened in a cframe motion from clicking, not really sure what to do, but should be simple enough.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
05 May 2014 09:49 PM
This should be funny:

local door=script.Parent
local doorCFrame=door.CFrame
local closed=true
local period=1
script.Parent.ClickDetector.MouseClick:connect(function()
if closed then
closed=false
--Open door
local t0=tick()
repeat
door.CFrame=doorCFrame*CFrame.new(0,door.Size.y/2,door.Size.z/2)*CFrame.Angles((tick()-t0)/period*math.pi/2,0,0)*CFrame.new(0,-door.Size.y/2,-door.Size.z/2)
wait()
until tick()-t0>period
door.CFrame=doorCFrame*CFrame.new(0,door.Size.y/2,door.Size.z/2)*CFrame.Angles(math.pi/2,0,0)*CFrame.new(0,-door.Size.y/2,-door.Size.z/2)
wait(5)

--Close door
t0=tick()
repeat
door.CFrame=doorCFrame*CFrame.new(0,door.Size.y/2,door.Size.z/2)*CFrame.Angles((1-(tick()-t0)/period)*math.pi/2,0,0)*CFrame.new(0,-door.Size.y/2,-door.Size.z/2)
wait()
until tick()-t0>period
door.CFrame=doorCFrame
closed=true
end
end)


Put a click detector in the door and put this script in the door too
Report Abuse
TrevorGaming99 is not online. TrevorGaming99
Joined: 25 Oct 2013
Total Posts: 241
05 May 2014 10:02 PM
The door seems to be rotating up, when i want it to rotate like a normal door. Is there any way to fix this? It will only rotate up, no other way.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
05 May 2014 10:03 PM
I'm glad it works, the rotating up was the funny part.
Report Abuse
TrevorGaming99 is not online. TrevorGaming99
Joined: 25 Oct 2013
Total Posts: 241
05 May 2014 10:04 PM
Do you think you may be able to fix that for me? I'm not really sure what to do about it.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
05 May 2014 10:06 PM
lolk

local door=script.Parent
local doorCFrame=door.CFrame
local closed=true
local period=1
script.Parent.ClickDetector.MouseClick:connect(function()
if closed then
closed=false
--Open door
local t0=tick()
repeat
door.CFrame=doorCFrame*CFrame.new(door.Size.x/2,0,door.Size.z/2)*CFrame.Angles(0,(tick()-t0)/period*math.pi/2,0)*CFrame.new(-door.Size.x/2,0,-door.Size.z/2)
wait()
until tick()-t0>period
door.CFrame=doorCFrame*CFrame.new(door.Size.x/2,0,door.Size.z/2)*CFrame.Angles(0,math.pi/2,0)*CFrame.new(-door.Size.x/2,0,-door.Size.z/2)
wait(5)

--Close door
t0=tick()
repeat
door.CFrame=doorCFrame*CFrame.new(door.Size.x/2,0,door.Size.z/2)*CFrame.Angles(0,(1-(tick()-t0)/period)*math.pi/2,0)*CFrame.new(-door.Size.x/2,0,-door.Size.z/2)
wait()
until tick()-t0>period
door.CFrame=doorCFrame
closed=true
end
end)

~untested
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
05 May 2014 10:07 PM
By the way, you can change how long it takes to open by changing the value of 'period' near the top to however many seconds you want it to take.
Report Abuse
TrevorGaming99 is not online. TrevorGaming99
Joined: 25 Oct 2013
Total Posts: 241
05 May 2014 10:07 PM
Works like a charm, thanks buddy.
Report Abuse
TrevorGaming99 is not online. TrevorGaming99
Joined: 25 Oct 2013
Total Posts: 241
05 May 2014 10:10 PM
Actually, not sure if you can do this, but are you able to fix it to where the door can have bricks on it, allowing the bricks to move with it?
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
05 May 2014 10:14 PM
blerg
Report Abuse
TrevorGaming99 is not online. TrevorGaming99
Joined: 25 Oct 2013
Total Posts: 241
05 May 2014 10:21 PM
^
I'll take that as a no? .-.
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