Advertisement
Arm4GeDon

unmodified closet

Oct 15th, 2022
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. local closet = script.Parent.Parent.Parent
  2. local prompt = script.Parent
  3. local promptExit = script.Parent.Parent.exit
  4. local used = closet.used
  5. local usedBy = closet.usedBy
  6.  
  7. used.Value = false
  8. usedBy.Value = ""
  9.  
  10. local humanoid = closet:WaitForChild("Humanoid")
  11.  
  12. local anim_open = closet:WaitForChild("open")
  13.  
  14. local open = humanoid:LoadAnimation(anim_open)
  15.  
  16. local humPosX = humanoid.Parent.HumanoidRootPart.Position.X
  17. local humPosY = humanoid.Parent.HumanoidRootPart.Position.Y
  18. local humPosZ = humanoid.Parent.HumanoidRootPart.Position.Z
  19.  
  20. local playerHum
  21.  
  22. local playerX
  23. local playerY
  24. local playerZ
  25.  
  26. local openSound = closet.prop_door_open
  27. local closeSound = closet.door_close
  28. local errorSound = closet.error
  29.  
  30. local username
  31.  
  32.  
  33. prompt.Triggered:Connect(function(player)
  34.     username = player.Name
  35.     print(username.. " wanna use the closet!!")
  36.     if used.Value == false and usedBy.Value == "" then
  37.         used.Value = true
  38.         player.Hidden.Value = true
  39.         usedBy.Value = player.Name
  40.         openSound:Play()
  41.         playerX = player.Character.HumanoidRootPart.Position.X
  42.         playerY = player.Character.HumanoidRootPart.Position.Y
  43.         playerZ = player.Character.HumanoidRootPart.Position.Z
  44.         prompt.Enabled = false
  45.         open:Play()
  46.         playerHum = player.Character.HumanoidRootPart
  47.         playerHum.Position = Vector3.new(humPosX, humPosY, humPosZ)
  48.         wait(0.2)
  49.         closeSound:Play()
  50.         wait(0.5)
  51.         promptExit.Enabled = true
  52.     else
  53.         print("already used by ".. username)
  54.         errorSound:Play()
  55.     end
  56. end)
  57.  
  58. promptExit.Triggered:Connect(function(player)
  59.     print(username)
  60.     if used.Value == true and usedBy.Value == username then
  61.         player.Hidden.Value = false
  62.         used.Value = false
  63.         usedBy.Value = ""
  64.         openSound:Play()
  65.         promptExit.Enabled = false
  66.         open:Play()
  67.         playerHum.Position = Vector3.new(playerX, playerY, playerZ)
  68.         wait(0.2)
  69.         closeSound:Play()
  70.         wait(1.5)
  71.         prompt.Enabled = true
  72.     end
  73. end)
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement