|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 05 May 2014 10:03 PM |
| I'm glad it works, the rotating up was the funny part. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 05 May 2014 10:07 PM |
| Works like a charm, thanks buddy. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 05 May 2014 10:21 PM |
^ I'll take that as a no? .-. |
|
|
| Report Abuse |
|
|