HowToRoblox

DoorHandler

Mar 2nd, 2021
703
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local door = script.Parent.Door
  2.  
  3. local lever = script.Parent.Lever
  4.  
  5. local leverOff = script.Parent.LeverOff
  6. local leverOn = script.Parent.LeverOn
  7.  
  8. local cd = lever:WaitForChild("ClickDetector")
  9.  
  10.  
  11. local ts = game:GetService("TweenService")
  12.  
  13.  
  14. local isOpen = false
  15.  
  16.  
  17. cd.MouseClick:Connect(function()
  18.    
  19.     isOpen = not isOpen
  20.    
  21.    
  22.     if isOpen then 
  23.        
  24.         ts:Create(lever, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {CFrame = leverOn.CFrame}):Play()
  25.            
  26.         door.Transparency = 1
  27.         door.CanCollide = false
  28.        
  29.        
  30.     else
  31.        
  32.         ts:Create(lever, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {CFrame = leverOff.CFrame}):Play()
  33.  
  34.         door.Transparency = 0
  35.         door.CanCollide = true
  36.     end
  37. end)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×