--[ FUNCTIONS ]--


game:GetService("UserInputService").WindowFocusReleased:Connect(function() -- tab in
	ReplicatedStorageEvent:FireServer(true)
end)

game:GetService("UserInputService").WindowFocused:Connect(function() -- tab out
	ReplicatedStorageEvent:FireServer(false)
end)

local uis = game:GetService("UserInputService")
local plrs = game:GetService("Players")
local lplr = plrs.LocalPlayer

local idle = false
local timer  = 0
uis.InputEnded:Connect(function()
	idle = true
	timer = 0
	while wait(1) do
		timer += 1
		if not idle then
			break
		end
		if timer >= 180 then
			ReplicatedStorageEvent:FireServer(true)
			break
		end
	end
end)

uis.InputBegan:Connect(function()
	idle = false
	ReplicatedStorageEvent:FireServer(false)
end)
