Advertisement
RoScripter

Roblox Door Script

Feb 29th, 2020
2,589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2. local door = script.Parent.Parent.Door
  3. local doorButton = script.Parent
  4. local clickDetector = script.Parent.ClickDetector
  5. local doorClosed = true
  6.  
  7. local doorClosedPosition = door.Position
  8. local doorClosedSize = door.Size
  9.  
  10. clickDetector.MouseClick:Connect(function()
  11.     local doorTweenInfo = TweenInfo.new(2)
  12.     local endPosition = {}
  13.     if doorClosed == true then
  14.         endPosition.Position = Vector3.new(door.Position.X, door.Position.Y + door.Size.Y/2, door.Position.Z)
  15.         endPosition.Size = Vector3.new(door.Size.X, 0, door.Size.Z)
  16.         doorButton.BrickColor = BrickColor.new("Really red")
  17.         doorClosed = false
  18.     else
  19.         endPosition.Position = doorClosedPosition
  20.         endPosition.Size = doorClosedSize
  21.         doorButton.BrickColor = BrickColor.new("Lime green")
  22.         doorClosed = true
  23.     end
  24.     local tween = TweenService:Create(door, doorTweenInfo, endPosition)
  25.     tween:Play()
  26. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement