Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local closet = script.Parent.Parent.Parent
- local prompt = script.Parent
- local promptExit = script.Parent.Parent.exit
- local used = closet.used
- local usedBy = closet.usedBy
- used.Value = false
- usedBy.Value = ""
- local humanoid = closet:WaitForChild("Humanoid")
- local anim_open = closet:WaitForChild("open")
- local open = humanoid:LoadAnimation(anim_open)
- local openSound = closet.prop_door_open
- local closeSound = closet.door_close
- local errorSound = closet.error
- local username
- prompt.Triggered:Connect(function(player)
- username = player.Name
- print(username.. " wanna use the closet!!")
- if used.Value == false and usedBy.Value == "" then
- used.Value = true
- player.Hidden.Value = true
- usedBy.Value = player.Name
- openSound:Play()
- prompt.Enabled = false
- open:Play()
- wait(0.2)
- closeSound:Play()
- wait(0.5)
- promptExit.Enabled = true
- else
- print("already used by ".. username)
- errorSound:Play()
- end
- end)
- promptExit.Triggered:Connect(function(player)
- print(username)
- if used.Value == true and usedBy.Value == username then
- player.Hidden.Value = false
- used.Value = false
- usedBy.Value = ""
- openSound:Play()
- promptExit.Enabled = false
- open:Play()
- wait(0.2)
- closeSound:Play()
- wait(1.5)
- prompt.Enabled = true
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement