Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------------------------------------------------
- -- Config
- local idleTime = 10
- local sound = script:WaitForChild("IdleSound")
- -----------------------------------------------------------------------------------------------------------------
- -- Input
- local updater = Instance.new("IntValue",script.parent)
- updater.Name = "LastUpdate"
- updater.Value = tick()
- function update()
- updater.Value = tick()
- end
- local mouse = game.Players.LocalPlayer:GetMouse()
- local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- local mouseSigs = {"Changed","Button1Down","Button2Down","Button2Up","KeyDown","KeyUp","WheelForward","WheelBackward"}
- for _,v in pairs(mouseSigs) do
- mouse[v]:connect(update)
- end
- for _,v in pairs(playerGui:GetChildren()) do
- v.Changed:connect(update)
- end
- playerGui.ChildAdded:connect(function (c)
- c.Changed:connect(update)
- end)
- -----------------------------------------------------------------------------------------------------------------
- -- The main stuff
- while wait() do
- if tick()-updater.Value >= idleTime then
- sound:Play()
- updater.Changed:wait()
- sound:Stop()
- end
- end
- -----------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement