Advertisement
CloneTrooper1019

For Brad

Feb 17th, 2014
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. -----------------------------------------------------------------------------------------------------------------
  2. -- Config
  3. local idleTime = 10
  4. local sound = script:WaitForChild("IdleSound")
  5. -----------------------------------------------------------------------------------------------------------------
  6. -- Input
  7. local updater = Instance.new("IntValue",script.parent)
  8. updater.Name = "LastUpdate"
  9. updater.Value = tick()
  10. function update()
  11.     updater.Value = tick()
  12. end
  13. local mouse = game.Players.LocalPlayer:GetMouse()
  14. local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  15. local mouseSigs = {"Changed","Button1Down","Button2Down","Button2Up","KeyDown","KeyUp","WheelForward","WheelBackward"}
  16. for _,v in pairs(mouseSigs) do
  17.     mouse[v]:connect(update)
  18. end
  19. for _,v in pairs(playerGui:GetChildren()) do
  20.     v.Changed:connect(update)
  21. end
  22. playerGui.ChildAdded:connect(function (c)
  23.     c.Changed:connect(update)
  24. end)
  25.  
  26. -----------------------------------------------------------------------------------------------------------------
  27. -- The main stuff
  28.  
  29. while wait() do
  30.     if tick()-updater.Value >= idleTime then
  31.         sound:Play()
  32.         updater.Changed:wait()
  33.         sound:Stop()
  34.     end
  35. end
  36. -----------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement