Advertisement
Arm4GeDon

Closet ServerScript

Oct 15th, 2022
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 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 openSound = closet.prop_door_open
  17. local closeSound = closet.door_close
  18. local errorSound = closet.error
  19.  
  20. local username
  21.  
  22.  
  23. prompt.Triggered:Connect(function(player)
  24.     username = player.Name
  25.     print(username.. " wanna use the closet!!")
  26.     if used.Value == false and usedBy.Value == "" then
  27.         used.Value = true
  28.         player.Hidden.Value = true
  29.         usedBy.Value = player.Name
  30.         openSound:Play()
  31.         prompt.Enabled = false
  32.         open:Play()
  33.         wait(0.2)
  34.         closeSound:Play()
  35.         wait(0.5)
  36.         promptExit.Enabled = true
  37.     else
  38.         print("already used by ".. username)
  39.         errorSound:Play()
  40.     end
  41. end)
  42.  
  43. promptExit.Triggered:Connect(function(player)
  44.     print(username)
  45.     if used.Value == true and usedBy.Value == username then
  46.         player.Hidden.Value = false
  47.         used.Value = false
  48.         usedBy.Value = ""
  49.         openSound:Play()
  50.         promptExit.Enabled = false
  51.         open:Play()
  52.         wait(0.2)
  53.         closeSound:Play()
  54.         wait(1.5)
  55.         prompt.Enabled = true
  56.     end
  57. end)
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement